public static int mystery(int value)
{
if(value <= 10)
return value * 3;
return value + mystery(mystery(value / 5)); // finished call 1
// call2 call 1 got back 27
// stops at call 2 and calls m(27)
}
Call stack
m(27)
m(9) returns 27
m(45)2 45 + ____
Explanation
call 1
is the inner call. When call 1
returns 27
,
the statement return value + mystery(mystery(value / 5));
becomes return 45 + mystery(27);