Advertisement
Guest User

Neo-Fibonacci (Dynamic Programming solution)

a guest
Feb 11th, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. #returns the nth Neo-Fibonacci number
  2. def neo_fib(n):
  3.     cache = [1, 1, 1]
  4.     for i in range(3, n):
  5.         cache.append(cache[-1] + cache[-2] + cache[-3])
  6.     return cache[n-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement