<p>public static int mystery(int n) {
if (n == 0)
return 1;
else return 3 * mystery(n - 1);
}
What value is returned as a result of the call mystery(5) ?
Theory behind my work:
since it asks what will be returned with mystery(5) I figured you just take the factorial of five and multiply it by the 3? Could someone try to explain the logic to these types of problems?
My work:
5! = 5 * 4! = 120
4! = 4 * 3! = 24
3! = 3 * 2! = 6
2! = 2</p>
<hr>
<p>So then 120 * 3 = 360</p>
<p>But the answer is 243, could anyone explain what I'm doing wrong?</p>