Skip to content

Instantly share code, notes, and snippets.

@onemouth
Last active December 17, 2015 21:49
Show Gist options
  • Save onemouth/5677760 to your computer and use it in GitHub Desktop.
Save onemouth/5677760 to your computer and use it in GitHub Desktop.
Sieve of Eratosthenes
sieve [] = []
sieve (x:xs) = x: sieve notMutipleOfX
where notMutipleOfX = filter (\n -> n `mod` x /= 0 ) xs
primes = sieve [2..]
main = print $ take 5000 primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment