Jump to content

Primality by trial division: Difference between revisions

m
→‎Sieve by trial division: whitespace (uniformity)
(→‎{{header|Haskell}}: rmv the 1st, inefficient version ; code tweak ; move here sieve by TD from SoE page)
m (→‎Sieve by trial division: whitespace (uniformity))
Line 485:
<lang haskell>primesTo m = 2 : sieve [3,5..m] where
sieve (p:xs) | p*p > m = p : xs
| True = p : sieve [x | x <- xs, rem x p /= 0]</lang>
 
To make it unbounded, the guard can not be simply discarded.
751

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.