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

MAX = 4000000

if __name__ == "__main__":
    prev = 0
    curr = 2

    total = 0

    while curr < MAX:
        total += curr

        # even numbers in fibonacci sequence can be calculated by:
        # next = (next * 4) + previous
        prev, curr = curr, curr * 4 + prev

    print(total)

@@ -334,33 +334,28 @@
 00%0A%0A
-if __name__ == %22__main__%22
+def even_fibonacci()
 :%0A  
@@ -360,16 +360,20 @@
     prev
+ious
  = 0%0A   
@@ -377,16 +377,19 @@
     curr
+ent
  = 2%0A%0A  
@@ -394,178 +394,244 @@
     
-total = 0%0A%0A    while curr %3C MAX:%0A        total += curr%0A%0A        # even numbers in fibonacci sequence can be calculated by:%0A        # next = (next * 4) + previous%0A
+yield prev%0A    yield curr%0A%0A    while True:%0A        previous, current = current, current * 4 + previous%0A        yield current%0A%0Aif __name__ == %22__main__%22:%0A    total = 0%0A%0A    for fib in even_fibonacci():%0A        if fib %3E= MAX:%0A    
         
 prev
@@ -630,42 +630,35 @@
     
-prev, curr = curr, curr * 4 + prev
+break%0A%0A        total += fib
 %0A%0A  

change python solution for problem 2 using generator function