Reputation: 11
import sys
sys.setrecursionlimit(10**8)
T = dict()
def downToZero(n):
if n in T : return T[n]
if n==1 : return 1
T[n] = 1+downToZero(n-1)
return T[n]
x = int(input())
print(downToZero(x))
Here is the code and it works for numbers like 100,1000 but when you input large numbers like 10,000, the console neither gives output nor it throws an error
Upvotes: 1
Views: 175
Reputation: 6298
You probably get something like:
Process finished with exit code -1073741571 (0xC00000FD)
The error code 0xC00000FD
indicates StackOverflow.
Setting max recursion level with setrecursionlimit
to 10**8
doesn't actually change the limit to that number; highest possible limit is platform-dependent (and smaller).
Upvotes: 1