Skip to content

Instantly share code, notes, and snippets.

@ppetr
Created May 9, 2016 19:44
Show Gist options
  • Save ppetr/8069a89589885dc4915df3c364c601c0 to your computer and use it in GitHub Desktop.
Save ppetr/8069a89589885dc4915df3c364c601c0 to your computer and use it in GitHub Desktop.
primes :: [Integer]
primes = 2 : filter isPrime [3,5..]
isPrime :: Integer -> Bool
isPrime n = all (\p -> n `rem` p /= 0) . takeWhile (\p -> p^2 <= n) $ primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment