ProjectEuler/problem2.py
2019-12-29 02:57:17 +01:00

10 lines
194 B
Python

def fib(limit=None):
a, b = 1, 2
yield a
yield b
while (not limit or a + b < limit):
a, b = b, a + b
yield b
print(sum(n for n in fib(4_000_000) if n % 2 == 0))