You are viewing a single comment's thread. Return to all comments →
Did a similar python approach
steps=[1,2,3] cache={} def climb(n): global cache leaves=0 if n < 0: return for s in steps: if n - s >= 0: if cache.has_key(n-s): subres=cache[(n-s)] else: subres=climb(n - s) cache[(n - s)] = subres leaves+=subres if n - s == 0: leaves += 1 return leaves
and climb(240) returns 2028382748046767387253483395022331055100978649577557465746184401
with no pain at all ;)
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 →
Did a similar python approach
and climb(240) returns 2028382748046767387253483395022331055100978649577557465746184401
with no pain at all ;)