1

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.)

Alex
  • 4,973
ogirkar
  • 2,844

1 Answers1

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