You are viewing a single comment's thread. Return to all comments →
No need for a buffer even, just 3 variables and extend the well-known method for calculating fibonacci numbers.
def paths(n): s0, s1, s2 = 1, 1, 2 for _ in range(n): s0, s1, s2 = s1, s2, s0 + s1 + s2 return s0
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Davis' Staircase
You are viewing a single comment's thread. Return to all comments →
No need for a buffer even, just 3 variables and extend the well-known method for calculating fibonacci numbers.