Skip to content

Instantly share code, notes, and snippets.

@byungyoonc
Created May 20, 2020 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byungyoonc/afcb5439f92f02a103b66c9fef18f543 to your computer and use it in GitHub Desktop.
Save byungyoonc/afcb5439f92f02a103b66c9fef18f543 to your computer and use it in GitHub Desktop.
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