You are viewing a single comment's thread. Return to all comments →
O(n) Python solution to get nth number in the modified fibonacci sequence.
def get_mod_fib(n): f1, f2, f3 = 1, 2, 4 for i in xrange(n-1): f1, f2, f3 = f2, f3, f1 + f2 + f3 return f1
Recursion: Davis' Staircase
You are viewing a single comment's thread. Return to all comments →
O(n) Python solution to get nth number in the modified fibonacci sequence.