Is there any other method or trick to find pi(x)[no. of primes upto x]other than the formula given by Euler..? (The other question is on prime arithmetic progressions.)
Asked
Active
Viewed 236 times
1
-
Possible duplicate of How to find number of prime numbers up to to N? – Isaac Browne May 05 '17 at 18:09
-
There is a great deal of literature on computing the prime counting function $\pi(x)$. Please start with the Wikipedia article and a search of previous Math.SE Questions on this subject. If you have a more specific question to ask, you can edit and perhaps the current post can be reconsidered. – hardmath May 06 '17 at 11:36
1 Answers
3
Values of π(n) have been calculated up to n = $10^{26}$. For a simple method that is significantly faster than just finding all the primes using a sieve and counting, you can look up Legendre's method for example here: https://programmingpraxis.com/2011/07/22/counting-primes-using-legendres-formula/ Legendre's method is quite simple. Faster methods run in $O (n^{2/3+\epsilon})$.
The "trick" is to avoid actually finding all the primes, if all you want to know is how many there are.
gnasher729
- 10,611
- 20
- 38