Project Euler #2: Even Fibonacci numbers

  • + 0 comments
    t = int(input().strip())
    for a0 in range(t):
        n = int(input().strip())
        
        a, b = 1, 2
        sum1 = 0
        
        while b < n:
            if b % 2 == 0:
                sum1 += b
            a, b = b, a+b
        
        print(sum1)