Is there any way to find prime number upto 10^9 or more in 1 second?
# | User | Rating |
---|---|---|
1 | tourist | 3624 |
2 | Um_nik | 3468 |
3 | wxhtxdy | 3329 |
4 | V--o_o--V | 3309 |
5 | Petr | 3297 |
6 | mnbvmar | 3255 |
7 | LHiC | 3250 |
8 | TLE | 3186 |
9 | Vn_nV | 3182 |
10 | dotorya | 3165 |
# | User | Contrib. |
---|---|---|
1 | Radewoosh | 195 |
2 | Errichto | 181 |
3 | neal | 159 |
4 | Ashishgup | 157 |
4 | PikMike | 157 |
6 | Petr | 156 |
7 | rng_58 | 154 |
7 | majk | 154 |
9 | Um_nik | 153 |
10 | Vovuh | 152 |
Is there any way to find prime number upto 10^9 or more in 1 second?
Name |
---|
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.
Thank You
I don't know much about this algorithm. Can you make a tutorial about it please ?
Yeap. Lehmer_algorithm or Efficient Prime Counting with the Meissel-Lehmer Algorithm
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
wow...thanks a lot.