forked from tdwojak/Python2017
19 lines
332 B
Python
19 lines
332 B
Python
![]() |
# coding=utf-8
|
||
|
'''
|
||
|
**ć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)``).
|
||
|
'''
|
||
|
|
||
|
def fibbonacci():
|
||
|
x = 0
|
||
|
y = 1
|
||
|
while True:
|
||
|
yield x
|
||
|
x, y = y, x+y
|
||
|
|
||
|
fibGen = fibbonacci()
|
||
|
n = 5
|
||
|
|
||
|
for i in range(n):
|
||
|
print fibGen.next()
|