Skip to content

Instantly share code, notes, and snippets.

@missett
Created December 21, 2013 15:13
Show Gist options
  • Save missett/8070630 to your computer and use it in GitHub Desktop.
Save missett/8070630 to your computer and use it in GitHub Desktop.
Haskell implementation of the Sieve of Eratosthenes algorithm for finding prime numbers.
sieve :: [Integer] -> [Integer]
sieve [] = []
sieve (x:xs)
| x < 2 = sieve xs
| otherwise = x : sieve (filter (\n -> n `mod` x /= 0) xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment