Question: I tried to find sum recursively but getting 'shell returned -1073741571' when I put large values for n. It is working for small values of n say 100. I feel this error is related to stack but not sure about its reason. I've increased recursion limit so that recursion limit is not hit. Here is my code:  

```
import sys
sys.setrecursionlimit(1000000)
print(sys.getrecursionlimit())
def get_sum(num):
    if num == 1:
        return 1
    else:
        return num + get_sum(num-1)

print(get_sum(10000))

```

Edit:
Specs: Windows 10, Python 3.7, Editor: Vim

Answer: 
setrecursionlimit only sets the limits within the python interpreter, on linux/unixish os'es check ulimit output for stack size limit.
When I run your code on my editor, I get this error:

> 
> File "J:/maskros/Pithon/test.py", line 8, in get\_sum
> 
> 
> return num + get\_sum(num-1)
> 
> 
> [Previous line repeated 997 more times]
> 
> 
> MemoryError: Stack overflow
> 
> 
> 

So it is because it hits the recursion limit, but when I set my recursion limit to a lower value, then it worked, If you reduce the setrecursion, to something like 10000, then it might work.

In comments it was noted that trying a lower value doesn't work.
The value mentioned did not work for me but this value did.

```
import sys
sys.setrecursionlimit(4999)
print(sys.getrecursionlimit())

def get_sum(num):
    if num == 1:
        return 1
    else:
        return num + get_sum(num-1)

print(get_sum(4998))

```

So I would guess and check till I get a good value.