"""
Each new term in the Fibonacci sequence is generated by adding
the previous two terms. By starting with 1 and 2, the first 10
terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values
do not exceed four million, find the sum of the even-valued terms.
"""
import math

def evenFib():
    # maxFib < fourmillion
    fibSum1 = 0
    fibSum2 = 1
    fibSum = 0
    even_fib_sum = 0
    # generate fibnumbers upto fourmillion
    while fibSum < 4000000:
        fibSum = fibSum1 + fibSum2
        fibSum1 = fibSum2
        fibSum2 = fibSum
        # while doing so check if the number generated is even or odd by doing %2
        if fibSum%2 == 0:
            # then add the number to a var
            even_fib_sum += fibSum
    return even_fib_sum
print(evenFib())

# SQROOT5 = math.sqrt(5)
# PHI = (1 + SQROOT5)/2
# print(math.pow(PHI, 4e^6) - (math.pow(-PHI, -4e^6)/SQROOT5))
