#Skip to menu

Even Fibonacci Numbers

First read the problem description.

Every third fibonacci number is even. Since \(F_n = F_{n-3} * 4 + F_{n-6}\), we initialy calculate \(F_3\) and \(F_6\) then \(F_9 = F_6 * 4 + F_3\), \(F_{12} = F_9 * 4 + F_6\) etc…

def Fn(Fn_3, Fn_6):
    return Fn_3 * 4 + Fn_6
Fn_6 = 0
Fn_3 = 2
sum = Fn_6 + Fn_3
while True:
    f = Fn(Fn_3, Fn_6)
    if f > 4_000_000:
        break
    sum += f
    Fn_6 = Fn_3
    Fn_3 = f

Source code of the solution(s):