Created
January 4, 2015 22:15
-
-
Save fbiville/d7fdcca8a55f69288795 to your computer and use it in GitHub Desktop.
Warning: super slow (when >= 10^6)
This file contains 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
sumPrimes :: Int -> Int | |
sumPrimes limit = _primes limit 2 [3,5..limit] | |
_primes :: Int -> Int -> [Int] -> Int | |
_primes limit sum [] = sum | |
_primes limit sum x = let x0=(head x) in _primes limit (sum+x0) (filter (\n -> n `mod` x0 /= 0) x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment