Advertisement
yaffar

Untitled

Oct 18th, 2021
840
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # ´Irjon egy rekurz´ıv függv´ enyt, amely kilist´ azza az els˝ o N
  2. # Fibonacci-sz´ amot (N-t param´ eterben kapja meg)!
  3.  
  4. def Fib(n):
  5.     if n == 1:
  6.         return 1
  7.     elif n == 0:
  8.         return 0
  9.     else:
  10.         return Fib(n-1) + Fib(n-2)
  11.        
  12. def FibList(n, a = 0):
  13.     if n > 0:
  14.         print(Fib(a))
  15.         FibList(n-1, a+1)
  16.     else:
  17.         return None
  18.  
  19. FibList(4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement