Hey, guys. I've got a question about Bucky's 31st Recursion tutorial.


here's the code in question:

int factorialFinder(int x){
    if(x == 1){
        return 1;
    }else{
        return x*factorialFinder(x-1);
    }
}

So my understanding is, when the program is run and let's say you pass the value 3 when calling the function, the if statement is ignored and the else block of code is run, returning the 3*factorialFinder(3-1) which runs the function again, again skipping the if statement and continuing on to the else block which returns the 2*factorialFinder(2-1). This time, the base case (if==1) is true and the function returns 1. But, why when you call the function in main does the function return the factorial (6) of x and not just 1 which is the last thing returned by the recursive function. I.e, when you call the function, why doesn't the function return 1?

Thanks for the help. I am a little puzzled.

Ps sorry about the run-on sentence.