I have a recusrive function and I am trying to exit with the return statement but for some reasons the return statement continue to call the recursive function. Here it is how my function looks like
public void Solve ()
if ( Stopping Condition )
A recursion is usually only useful if it returns a value. The calling method uses that value. Look at this factorial function, where the method calls itself.
Also a recursion should have a base case. That means if a certain value is found (in the case of factorial, 0), a predetermined result is returned, in this case 1. The recursion should converge towards its base case, otherwise it is liable to go on for ever (or at least until it exhausts your stack space or memory available).
Note there are also exclusions; negative values don't have factorials, and values > 21 (I think) give arithmetic overflow. Hence the Exceptions.
Note the letter L to make the 1 into a long.