Fibonacci series recursion error

Ian Kelly ian.g.kelly at gmail.com
Tue May 3 18:31:29 EDT 2011


On Tue, May 3, 2011 at 3:41 PM, Chris Angelico <rosuav at gmail.com> wrote:
> 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).

Depends what you mean by "safe".  A back-of-the-envelope calculation
shows that with modern technology it would take more than 10 ** 257
years to complete.  That puts it well into the Dark Era of the
universe, long after the black holes will have decayed, when I suspect
it will be difficult to find a continued power source for the computer
to run.  And even if it somehow is still running, the process memory
will have been so thoroughly muddled by cosmic rays that the final
result of the calculation will be utterly worthless.



More information about the Python-list mailing list