CS205

Recursion Tracing

Trace through recursive function calls to find the answer.

Question 1 of 4Score: 0 pts
Factorial Result

What does factorial(5) return?

int factorial(int n) {
    if (n <= 1) return 1;
    return n * factorial(n - 1);
}

// factorial(5) = 5 * factorial(4)
//              = 5 * 4 * factorial(3)
//              = 5 * 4 * 3 * factorial(2)
//              = 5 * 4 * 3 * 2 * factorial(1)
//              = 5 * 4 * 3 * 2 * 1