Guest User

Fibonacci sequence

a guest
May 12th, 2011
260
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cached_results = []
  2.  
  3. def fib_rec(n):
  4.     for i in range(0, n):
  5.         if i < 2:
  6.             cached_results.append(i)
  7.         else:
  8.             cached_results.append(cached_results[i-2] + cached_results[i-1])
  9.    
  10.     return cached_results
  11.            
  12. if __name__ == "__main__":
  13.     print fib_rec(40)
RAW Paste Data