Created
May 20, 2020 06:57
-
-
Save byungyoonc/afcb5439f92f02a103b66c9fef18f543 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
module ProjectEuler2 | |
( printAnswer | |
) where | |
fibonacci :: [Int] -> Int -> [Int] | |
fibonacci (n:m:xs) x | |
| n+m > x = reverse (n:m:xs) | |
| otherwise = fibonacci (n+m:n:m:xs) x | |
fiblim :: Int -> [Int] | |
fiblim = fibonacci [2,1] | |
printAnswer :: IO () | |
printAnswer = print (show (sum (filter (\x -> mod x 2 == 0) (fiblim 4000000)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment