0
I found this question in challenge but I can't understand how it got 24. What I missed?
2 Answers
+ 4
Here's a step-by-step breakdown of the calculation:
f(4) is called and returns 4 * f(3)
f(3) is called and returns 3 * f(2)
f(2) is called and returns 2 * f(1)
f(1) is called and returns 1
The recursive calls start unwinding, with f(2) returning 2 * 1 = 2,
f(3) returning 3 * 2 = 6,
and f(4) returning 4 * 6 = 24. This is the final result that is output by the code.
+ 2
Than you!