1
0
forked from tdwojak/Python2018
Python2018/labs04/task02.py
2018-06-02 21:48:54 +02:00

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)