Skip to content

Instantly share code, notes, and snippets.

@astro
Created October 30, 2008 21:58
Show Gist options
  • Save astro/21156 to your computer and use it in GitHub Desktop.
Save astro/21156 to your computer and use it in GitHub Desktop.
is_prime 1 = False
is_prime 2 = True
is_prime x = not (any (\n -> x `rem` n == 0) [2..(x `div` 2)])
primes = [x | x <- [1..], is_prime x]
primes_until n = takeWhile (<= n) primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment