Primality by trial division: Difference between revisions

→‎Segmented Generate and Test: code tweak - about 10% slower cmpld, x4 faster interp'd in GHCi
(→‎Segmented Generate and Test: code tweak - about 10% slower cmpld, x4 faster interp'd in GHCi)
Line 490:
<lang haskell>primes = 2 : 3 : sieve 5 9 (drop 2 primes) 0 where
sieve x q ps k = let fs = take k (tail primes) in
[nfilter |((`all` nfs) <-. ((/=0).) . rem) [x,x+2..q-2], and [rem n f /= 0 | f <- fs]]
++ sieve (q+2) (head ps^2) (tail ps) (k+1)</lang>
 
751

edits