Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. def fib(n,cash):
  2. if n==0:
  3. return 1
  4. if cash[n-1] is not None:
  5. return cash[n-1]
  6. if n==1:
  7. return 1
  8. cash[n-1]=fib(n-1,cash)+fib(n-2,cash)
  9. return cash[n-1]
  10. n=int(input())
  11. print(fib(n,[None]*n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement