Advertisement
Guest User

Untitled

a guest
Nov 17th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. memo = {0:0, 1:1}
  2.  
  3. @profile
  4. def fib(n):
  5.     if not n in memo:
  6.         memo[n] = fib(n-1) + fib(n-2)
  7.     return memo[n]
  8.        
  9. n = 0
  10. loop = int(raw_input("Input how many Fibonacci numbers you wish to calculate: "))
  11.    
  12. for n in range (1, loop):
  13.     a = fib(n)
  14.     print a
  15.     n += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement