""" 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 time

start_time = time.time()

fib_last = 0
fib_current = 1
fib_next = 1
sum_ = 0

while fib_next <= 4000000:
    fib_next = fib_current + fib_last
    fib_last = fib_current
    fib_current = fib_next
    if fib_next % 2 is 0:
        sum_ += fib_next

print("\nAnswer: {}".format(sum_))
print("--- Runtime: %s seconds ---" % (time.time() - start_time))
