Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ´Irjon egy rekurz´ıv függv´ enyt, amely kilist´ azza az els˝ o N
- # Fibonacci-sz´ amot (N-t param´ eterben kapja meg)!
- def Fib(n):
- if n == 1:
- return 1
- elif n == 0:
- return 0
- else:
- return Fib(n-1) + Fib(n-2)
- def FibList(n, a = 0):
- if n > 0:
- print(Fib(a))
- FibList(n-1, a+1)
- else:
- return None
- FibList(4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement