daily pastebin goal

Neo-Fibonacci (Dynamic Programming solution)

a guest Feb 11th, 2015 263 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand