Skip to content

Instantly share code, notes, and snippets.

@J0J0
Created September 22, 2014 12:53
Show Gist options
  • Save J0J0/3c61891d8ec9157a38ab to your computer and use it in GitHub Desktop.
Save J0J0/3c61891d8ec9157a38ab to your computer and use it in GitHub Desktop.
fibs :: (Integral a) => [a]
fibs = 1 : 1 : zipWith (+) fibs (tail fibs)
--https://projecteuler.net/problem=2
problem2 :: (Integral a, Integral b) => a -> b
problem2 n
| n <= 1 = 0
| otherwise = sum (filter even (takeWhile (<= (fromIntegral n)) fibs))
answer = problem2 (4*10^6)
main = print $ answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment