2 ms·
It takes a constant space since it is not even recursive. The decorator makes it a non-recursive function with a loop. It'll effectively side-steps the recurs
by ericfrederich 9y ago
It takes a constant space since it is not even recursive. The decorator makes it a non-recursive function with a loop.
It'll effectively side-steps the recursion limit in Python. For runs under the limit anyway, it'd be interesting to see whether it's any faster. It trades function call overhead for exception handling overhead.
By the way, the first example where it has `return 1` is wrong. It shoudl `return accumulator`. Clicking the GitHub link someone suggested this in December.