Skip to content

Instantly share code, notes, and snippets.

@mvaldesdeleon
Created August 10, 2018 21:16
Show Gist options
  • Save mvaldesdeleon/b5ae2bcabc7b81442ad38224a8363967 to your computer and use it in GitHub Desktop.
Save mvaldesdeleon/b5ae2bcabc7b81442ad38224a8363967 to your computer and use it in GitHub Desktop.
fibs :: Num a => [a]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
isEven :: Integral a => a -> Bool
isEven x = x `mod` 2 == 0
main :: IO ()
main = print $ takeWhile (\x -> x <= 4000000) (filter isEven fibs)
-- [0,2,8,34,144,610,2584,10946,46368,196418,832040,3524578]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment