forked from tdwojak/Python2017
21 lines
406 B
Python
21 lines
406 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 Fibonacci(n):
|
|
|
|
x = 0
|
|
print(x)
|
|
y = 1
|
|
print(y)
|
|
z = 0
|
|
z = x + y
|
|
print (z)
|
|
|
|
for i in range(2, n):
|
|
x = y
|
|
y = z
|
|
z = x + y
|
|
print(z)
|
|
|
|
|
|
Fibonacci(19) |