How can the maximum recursion depth modified? I think, in Python, maximum recursion possible is 987 because of this.
def harmonic_sum(n):
if(n==1):
return 1
else:
h_sum=(1/n)+harmonic_sum(n-1)
return h_sum
>>> harmonic_sum(986)
7.471379033179059
>>> harmonic_sum(987)
RuntimeError: maximum recursion depth exceeded in comparison
I wrote a recursive function to calculate the power of 2 to nth and it also fails when it reaches 987.
Is there some ways to modify the maximum recursion depth allocated?
Please don't suggest an iterative way to solve the problem. This is my effort to make recursion well-established in my head. I am surfing internet and solving as much recursive problem possible with timer in my hand.