Project Euler #2: Even Fibonacci numbers

  • + 0 comments

    a very optimized solution with recursion

    python def fib_sum_even(n, current, nextnum, sum_even): if current>n: return sum_even if current % 2 == 0: sum_even += current return fib_sum_even(n, nextnum, current+nextnum, sum_even)