You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
244 B

prev_two = 1
prev_one = 0
fib_num = 0
sum = 0
while True:
if fib_num > 4000000:
break
fib_num = prev_one + prev_two
if fib_num % 2 == 0:
sum += fib_num
prev_two = prev_one
prev_one = fib_num
print(sum)