Hello I'm a first year CS student attempting to understand why the return value is not '1' when using the Recursive function for example a simple Factorial function.
int factorial(int x) {
if (x==1) {
return 1;
} else {
return x * factorial(x - 1);
}
}
I understand the factorial algorithm part but it eventually descends until it returns 1, so how does it return the answer instead of '1'???
- Thank you to all who reply :)