logo CodeStepByStep logo

RecursionMysteryMinus

Language/Type: C# recursion

For each call to the following recursive method, write the value that would be returned.

public static int RecursionMysteryMinus(int x, int y)
{
    if (x < y)
    {
        return x;
    }
    else
    {
        return RecursionMysteryMinus(x - y, y);
    }
}

(Side note: What is the method really doing?)

RecursionMysteryMinus(6, 13)
RecursionMysteryMinus(14, 10)
RecursionMysteryMinus(37, 10)
RecursionMysteryMinus(8, 2)
RecursionMysteryMinus(50, 7)

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.