logo CodeStepByStep logo

RecursionMystery5

Language/Type: C# recursion

For each of the calls to the following recursive method below, indicate what value is returned:

public static int RecursionMystery5(int a, int b)
{
    if (a < 10 || b < 10)
    {
        return a + b;
    }
    else if (a > b)
    {
        int x = RecursionMystery5(a / 2, b / 2);
        int y = RecursionMystery5(b, a - b);
        return x + y;
    }
    else
    {
        return RecursionMystery5(a, b / 2);
    }
}
RecursionMystery5(11, 18)
RecursionMystery5(26, 12)
RecursionMystery5(32, 48)

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.