[Haskell-beginners] Performance of Prime Generator

Zhi-Qiang Lei zhiqiang.lei at gmail.com
Sat Jan 21 17:28:34 CET 2012


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.

On Jan 21, 2012, at 10:38 PM, Ertugrul Söylemez wrote:

> Zhi-Qiang Lei <zhiqiang.lei at gmail.com> wrote:
> 
>> Hi, what do you mean "more naive wheel trial division"?
> 
> Just use a wheel like 2*3*5 and don't bother only dividing by primes.
> Trying to divide only by primes takes more time than just living with
> the few percent nonprimes that slip through the wheel.
> 
> Or better yet, use a sieve like the Sieve of Eratosthenes or the Sieve
> of Atkin.  Those are fairly easy to implement in Haskell.
> 
> 
> Greets,
> Ertugrul
> 
> -- 
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


Best regards,
Zhi-Qiang Lei
zhiqiang.lei at gmail.com




More information about the Beginners mailing list