Recursive functions can be tricky. Remember, calling "return" only returns for the most recent function.
See attached image.
Calling return when inside the fourth call of the recursive function, only exits that fourth call. The other three calls of the function are still running.
In some cases, it is better to use an iterative approach such as a for loop or while loop instead of a recursive approach.
Best Answer