@@ -0,0 +1,27 @@
+{-
+Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
+1, 2, 3, 5, 8, 13, 21, 34, 55, 89
+By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
+-}
+
+--solution_inner :: Int -> Int
+--solution_inner x = go' x 0 where
+-- go' 4000000 y = y
+-- go' x y = go' (x+1) ((solution_is_div x) + y)
+is_even :: Int -> Int
+is_even x =
+ case (mod x 2) of
+ 0 -> x
+ _ -> 0
+solution :: Int
+solution =
+ go' 1 2 0 where
+ limit = 4000000
+ go' x y sum
+ | x < limit && y < limit = go' y (x + y) $! ((is_even y) + sum)
+ | otherwise = sum
+main :: IO ()
+main = putStrLn ("Solution: " ++ show solution)