Created
September 9, 2014 11:55
-
-
Save Heimdell/e646f6d7efbec3d6fed0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
primes = filter isPrime [1..] | |
isPrime p = case p of | |
1 -> False | |
2 -> True | |
n -> notDivisor n `all` lowerThanSqrt | |
where | |
lowerThanSqrt = takeWhile (\p -> p * p <= n) primes | |
notDivisor n d = n `mod` d /= 0 | |
test = print (take 100 primes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment