Problem 2
This commit is contained in:
parent
ae41caa19d
commit
5b51f10563
9
problem2.py
Normal file
9
problem2.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
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))
|
Loading…
Reference in a new issue