Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
10
Task/Fibonacci-sequence/Python/fibonacci-sequence-10.py
Normal file
10
Task/Fibonacci-sequence/Python/fibonacci-sequence-10.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def fib():
|
||||
"""Yield fib[n+1] + fib[n]"""
|
||||
yield 1 # have to start somewhere
|
||||
lhs, rhs = fib(), fib()
|
||||
yield next(lhs) # move lhs one iteration ahead
|
||||
while True:
|
||||
yield next(lhs)+next(rhs)
|
||||
|
||||
f=fib()
|
||||
print [next(f) for _ in range(9)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue