Last active
January 1, 2016 15:39
-
-
Save mikamix/8165544 to your computer and use it in GitHub Desktop.
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
euler10 = sum $ takeWhile (< 2000000) (2 : 3 : findPrimes [3] 5) | |
findPrimes primes number | |
| isNotPrime = findPrimes primes (number + 2) | |
| otherwise = number : findPrimes (number : primes) (number + 2) | |
where | |
isNotPrime = any isModulable [p| p <- primes, p ^ 2 <= number] | |
isModulable p = number `mod` p == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment