# Once fibonacci(n) is computed, table[n] will contain its value. table = [] #Initially, we haven't computed any values. def fibonacci(n): # Make sure the table is big enough. while len(table) <= n: table.append(None) # Now we can put the value into the table if it isn't already there. if table[n]==None: if n==0: table[n] = 0 elif n==1: table[n] = 1 else: table[n] = fibonacci(n-1) + fibonacci(n-2) # Now the value is in the table, so we can return it. return table[n]