1
0
forked from tdwojak/Python2017
Python2017/labs03/zadanie 2.py

25 lines
536 B
Python
Raw Normal View History

2017-12-03 13:44:41 +01:00
"""
**ć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))