The expression fun(--i) * i * fun(--i)
exhibits undefined behavior. So we can't make any assumptions about what that would produce. If you are curious why it is undefined, then please read: Why are these constructs (using ++) undefined behavior?
We can attempt to remove the undefined behavior, and talk about that though:
int fun(int i) {
if(i<2)
return 1;
else {
return fun(i - 1) * (i - 1) * fun(i - 2);
}
}
fun(5)
should and does produce 48 with the corrected code. And if we need to prove that...
fun(0) == 1
fun(1) == 1
fun(2) == fun(1) * 1 * fun(0) == 1 * 1 * 1 == 1
fun(3) == fun(2) * 2 * fun(1) == 1 * 2 * 1 == 2
fun(4) == fun(3) * 3 * fun(2) == 2 * 3 * 1 == 6
fun(5) == fun(4) * 4 * fun(3) == 6 * 4 * 2 == 48