Created
March 29, 2012 16:05
-
-
Save davorb/2239021 to your computer and use it in GitHub Desktop.
project euler 2
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
-- the sum of the even valued values of the fibonacci sequence | |
-- whose values do not exeed four million | |
fibonacci 0 = 0 | |
fibonacci 1 = 1 | |
fibonacci n = fibonacci (n-1) + fibonacci (n-2) | |
fib = [fibonacci n | n <- [0..]] | |
answer2 = sum $ filter even $ takeWhile (<4000000) fib | |
main = putStrLn $ show answer2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment