In [12]:
a, b = 1, 1
s = 0
while True:
    if b > 4000000:
        break
    if b%2 == 0:
        print b
        s = s+b
    a, b = b, a+b
print s


2
8
34
144
610
2584
10946
46368
196418
832040
3524578
4613732

In [17]:
a, b = 1, 1
total = 0
while b < 4000000:
    if b % 2 == 0:
        print b
        total = total +b
    a, b = b, a+b
print total


2
8
34
144
610
2584
10946
46368
196418
832040
3524578
4613732

In [ ]:
1*2*3*4*5*6*7*