Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- memo = {0:0, 1:1}
- @profile
- def fib(n):
- if not n in memo:
- memo[n] = fib(n-1) + fib(n-2)
- return memo[n]
- n = 0
- loop = int(raw_input("Input how many Fibonacci numbers you wish to calculate: "))
- for n in range (1, loop):
- a = fib(n)
- print a
- n += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement