public static int mystery(int value)
{
if(value <= 10)
return value * 3;
return value + mystery(mystery(value / 5)); // finished call 2
// call2 call 1 got back 69
// computes 45 + 69, which is 114
// stops and returns 114
}
Call stack
m(9) returns 27
m(3) returns 9
m(15) 15 + 27 returns 42
m(5) returns 15
m(27) 27 + 42 returns 69
m(9) returns 27
m(45)2 45 + 69 returns 114
Navigation
Back to Step 13
Back to main example
Review recursive method tracing with AP CS Tutor Brandon Horn.