public int mystery(int b)
{
if (b == 0)
return 0;
if (b % 2 == 0)
return mystery(b - 1) + 3; // call 1
else
return mystery(b - 1) + 2; // call 2
// finished call 2, got back 5
// adds 2
// stops and returns 7
}
Call stack
m(0) returns 0
m(1) returns 2
m(2) returns 5
m(3) returns 7
m(4)1
m(5)2