Skip to content

Instantly share code, notes, and snippets.

@ChrisBuchholz
Created December 10, 2012 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisBuchholz/4250323 to your computer and use it in GitHub Desktop.
Save ChrisBuchholz/4250323 to your computer and use it in GitHub Desktop.
primes
primes = take (10^6) $ [n | n <- [2..], prime n]
where
prime n
| n < 2 = False
| n == 2 = True
| null [x | x <- [2..(floor . sqrt $ fromIntegral n)], n `mod` x == 0] = True
| otherwise = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment