3.2. Primes (with low efficiency)
primes = sieve [2..] where sieve (x:xs) = x:(sieve [a | a <- xs, a `mod` x /= 0 ]) |
- This code has low efficiency because it uses division (or modulo) a lot.
primes = sieve [2..] where sieve (x:xs) = x:(sieve [a | a <- xs, a `mod` x /= 0 ]) |
Written by Shlomi Fish