forked from tdwojak/Python2017
25 lines
536 B
Python
25 lines
536 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)``).
|
||
|
"""
|
||
|
|
||
|
def FiboGenerator(n):
|
||
|
for i in range(n):
|
||
|
if n==0:
|
||
|
return 1
|
||
|
elif n==1:
|
||
|
return 1
|
||
|
else:
|
||
|
return FiboGenerator(n-1)+FiboGenerator(n-2)
|
||
|
|
||
|
"""
|
||
|
def tests(f):
|
||
|
inputs = [0,1,2,3,4,5,6,7,8]
|
||
|
for input in zip(inputs):
|
||
|
print(f(2))
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
print(tests(FiboGenerator))
|
||
|
"""
|
||
|
|
||
|
print(FiboGenerator(1))
|