Why is this blowing the stack, thought it was tail-recursive...
ssecorp
circularfunc at gmail.com
Sat Jul 12 12:20:58 EDT 2008
def fib(n):
def fibt(a, b, n):
if n <= 1:
return b
else:
return fibt(b, a + b, n - 1)
if n == 0:
return 0
else:
return fibt(0, 1, n);
and can memoization speed up this even more? tesintg with memoization
doesnt really say anything because it is so fast it is instant anyway.
(the classic easy-redable exponential fib-function can obv be helped
enormously with memoization though.)
More information about the Python-list
mailing list