forked from tdwojak/Python2017
task02 (labs03) done
This commit is contained in:
parent
2b44ac6ffc
commit
4d960a7cc0
21
labs03/task2.py
Normal file
21
labs03/task2.py
Normal file
@ -0,0 +1,21 @@
|
||||
"""**ć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)
|
Loading…
Reference in New Issue
Block a user