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

#we know simply from the example here that the 2nd term and every 3rd term thereafter will be even 
x=0
array = [1,2]
sum1=2
while x < 4000000:
    x=array[-1]+array[-2]
    array.append (array[-1]+array[-2])
    
    if x % 2 == 0:
        sum1 += x
        

print("The sum of the even valued terms in the Fibonacci sequence is",sum1)

