Unsocial_A's blog

By Unsocial_A, history, 7 months ago, In English,

Is there any way to find prime number upto 10^9 or more in 1 second?

 
 
 
 
  • Vote: I like it  
  • +13
  • Vote: I do not like it  

»
7 months ago, # |
Rev. 5   Vote: I like it +30 Vote: I do not like it

Yes. It can be easily using Meisell-Lehmer algorithm to calculate the numbers of prime up to n in O(n^{2/3}).

or you can see F.Four Divisors.

»
7 months ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

If you want to enumerate all the primes upto 10^9 in 1 second, Segment Sieve of Eratosthenes plus Wheel Factorization will help a lot.

An example using primes 2, 3, 5, 7, 11, 13, code