I'm trying to write a simple recursive sum function in c++:
long long int recursum(long long int n){
if(n==1)
return 1;
else
return recursum(n-1)+n;
}
This should work, but I get segfaults with values greater than ~250000.I am very sure that this should work, as it is a very simple recursion with a terminal statement.