Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fib(n,cash):
- if n==0:
- return 1
- if cash[n-1] is not None:
- return cash[n-1]
- if n==1:
- return 1
- cash[n-1]=fib(n-1,cash)+fib(n-2,cash)
- return cash[n-1]
- n=int(input())
- print(fib(n,[None]*n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement