[Haskell-cafe] Re: Optimization fun

Lennart Augustsson lennart at augustsson.net
Sun Feb 11 15:22:09 EST 2007


Yes, and that's pretty much what my version does (and what the  
original tried to do?).

On Feb 11, 2007, at 20:14 , DavidA wrote:

> If you want it fast, don't use a sieve method at all (or a wheel  
> method) - use
> trial division:
>
> primes = 2 : [p | p <- [3,5..], trialDivision primes p]
>
> trialDivision (p:ps) n | r == 0    = False
>                        | q < p     = True
>                        | otherwise = trialDivision ps n
>                        where (q,r) = n `quotRem` p
> trialDivision [] _ = True
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list