Sum of Fibonacci numbers
- by Rafal
Hi,
I'm rather new to Haskell. The problem is to find the sum of all even Fibonacci numbers not greater than 4 million. I can't use lists.
If I understand correctly, the below solution is wrong, because it uses lists:
my_sum = sum $ filter (even) $ takeWhile (< 4000000) fibs
Where fibs is the list of all Fibonacci numbers.
Somehow, I find it difficult not to think in Haskell in terms of lists. Could anyone guide me to a solution to this problem?
Regards