RosettaCodeData/Task/Fibonacci-sequence/Python/fibonacci-sequence-14.py

12 lines
180 B
Python
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
from itertools import islice
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
def fib():
yield 0
yield 1
a, b = fib(), fib()
next(b)
while True:
yield next(a)+next(b)
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
print(tuple(islice(fib(), 10)))