# 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.

def get_even_fibonacci_sum(max_fib_val):
    index1 = 0
    index2 = 1
    totalSum = 0
    while (index1 + index2) < max_fib_val:
        indexSum = index1 + index2
        if indexSum % 2 == 0:
            totalSum += indexSum
        index1 = index2
        index2 = indexSum
    return totalSum

if __name__ == "__main__":
	print(get_even_fibonacci_sum(4000000))