Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fib_calc(n, memo):
- if n in memo:
- return memo[n]
- if n <= 2:
- return 1
- result = fib_calc(n-1, memo) + fib_calc(n-2, memo)
- memo[n] = result
- return result
- n = int(input())
- print(fib_calc(n, {}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement