Skip to content

Instantly share code, notes, and snippets.

@davorb
Created March 29, 2012 16:05
Show Gist options
  • Save davorb/2239021 to your computer and use it in GitHub Desktop.
Save davorb/2239021 to your computer and use it in GitHub Desktop.
project euler 2
-- 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