Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 0 and 1, the first 12 terms will be:
0, 1, 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.
In [1]:
series = [0,1]
i = 0
while series[i]+series[i+1] <= 4000000:
series.append(series[i]+series[i+1])
i= i+1
print("Answer: " + str(sum(v for v in series if v % 2.0 == 0)))
I worked with Jessi Pilgram on this problem.
In [ ]:
# This cell will be used for grading, leave it at the end of the notebook.