# where the function has problem? n = 900 is OK , but n = 1000 is ERROR

Mon Aug 1 05:23:20 EDT 2011

```The maximum depth of the Python interpreter stack is limited to 1000 calls
by default.  You can get it by import sys; sys.getrecursionlimit() and set a
new value to sys.setrecursionlimit(new_value)

On Mon, Aug 1, 2011 at 4:11 PM, jc <chenjii at gmail.com> wrote:

> # Get Fibonacci Value
> #    Fibonacci(N) = Fibonacci(N-1) + Fibonacci(N-2)
> #
> # n = 900 is OK
> # n = 1000 is ERROR , Why
> #
> # What Wrong?
> #
>
> cache = []
>
> def fibo( n ):
>
>    try:
>        if cache[n] != -1:
>            return cache[n]
>        else:
>            if 0 == n:
>                r = 0
>            elif 1 == n:
>                r = 1
>            else:
>                r = fibo(n-1) + fibo(n-2)
>
>            cache[n] = r
>            return r
>    except:
>        print "EXCEPT: " + str(n)
>
>
> if __name__ == '__main__':
>
> # This n = 900 is OK
> # But n = 1000 is ERROR
>
>    n = 900
>    cache = range(0 , n + 1 , 1)
>
>    for i in cache:
>        cache[i] = -1
>
>    print "Fibo(" + str(n) + ") = " + str(fibo(n))
>    print "\n"
>    print "\n"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110801/f91a29d3/attachment.html>
```