Skip to content

Instantly share code, notes, and snippets.

@fetburner
Last active December 15, 2015 13:49
Show Gist options
  • Save fetburner/5270096 to your computer and use it in GitHub Desktop.
Save fetburner/5270096 to your computer and use it in GitHub Desktop.
エラトステネスのふるい
primes :: (Integral a) => [a]
primes = sieve [2 .. ]
where
sieve (p : qs) = p : sieve (filter (\q -> q `mod` p /= 0) qs)
main = print . sum . takeWhile ( <= 2000000) $ primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment