re: Project Euler #2 - Even Fibonacci numbers VIEW POST

FULL DISCUSSION
 

Elm

Algorithm code

sumEven a sum =
  if a % 2 == 0 then
    a + sum
  else
    sum

sumfibs max a b sum =
  if a > max then
    sum
  else
    sumfibs max b (a + b) (sumEven a sum)

To call, max Fib value = 4000000, start with first 2 Fibs (1 and 2), initial sum = 0.

sumfibs 4000000 1 2 0

Pretty understandable, no?

code of conduct - report abuse