10 lines
194 B
Python
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))
|