Fibonacci series recursion error

Chris Angelico rosuav at gmail.com
Tue May 3 17:41:32 EDT 2011


On Wed, May 4, 2011 at 3:10 AM, harrismh777 <harrismh777 at charter.net> wrote:
> If your point is that the infinite process is the problem, I agree. But my
> point is that the cpu crunch and the rate at which the call stack is filled
> has to do with the double call (which never finds tail processing).

The double call _does not_ affect it. Failing to terminate recursion
_does_. I don't know what you mean by "cpu crunch" but the call stack
is going to get n entries. On the Python 2.6 on this system,
sys.getrecursionlimit() returns 1000, meaning that you can calculate
fib(1000) safely (okay, probably not quite as there'll be a few used
for other things, but fib(900) would be safe).

Chris Angelico



More information about the Python-list mailing list