
21 Jan
2012
21 Jan
'12
5:18 p.m.
Zhi-Qiang Lei
Well, thanks, so far I have tried wheel only and Sieve of Eratosthenes only approaches. They both failed. When the numbers is between 999900000 and 1000000000, they can take more than a hour on my laptop.
Indeed, you're right. The method is too slow for numbers of that scale. I suggest trying the Sieve of Atkin, which performs quadratically faster than the Sieve of Eratosthenes. I haven't tried it, but an equivalent C implementation can easily compute the first 10^9 prime numbers within seconds. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/