Skip to content

Instantly share code, notes, and snippets.

@fbiville
Created January 4, 2015 22:15
Show Gist options
  • Save fbiville/d7fdcca8a55f69288795 to your computer and use it in GitHub Desktop.
Save fbiville/d7fdcca8a55f69288795 to your computer and use it in GitHub Desktop.
Warning: super slow (when >= 10^6)
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