public static int Mystery(int a,int b)
{
if (b == 0)
return 0;
if (b % 2 == 0)
{
return Mystery(a + a, b / 2);
}
else
{
return Mystery(a + a, b / 2) + a;
}
}
Hello guys can you please tell me what's the difference between using a return Mystery(a +a ...etc) and calling it simply by using Mystery(a + a)? What I have been thinking till now is that when I use return something it actually creates a way back for the recursion to come back and using recursion without return (ex.Mystery( a + a etc..)) goes only in depth without actually leaving any path to go back. Thanks!