forked from tdwojak/Python2018
20 lines
381 B
Python
20 lines
381 B
Python
"""
|
|
**ćwiczenie 2**
|
|
Napisz generator, który będzie zwracać ``n`` kolejnych liczb ciągu Fibonacciego (``F(0)=1, F(1)=1, FN=F(N-1) + F(N-2)``).
|
|
"""
|
|
|
|
import itertools as it
|
|
|
|
n = int(input('Number of occursion: '))
|
|
|
|
def fibo():
|
|
a, b = 0, 1
|
|
while 1:
|
|
yield a
|
|
b = a + b
|
|
yield b
|
|
a = a+b
|
|
gen = fibo()
|
|
|
|
for i in it.islice(fibo(), n):
|
|
print(i) |