logo CodeStepByStep logo

recursionMysteryMinus

Language/Type: C++ recursion

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

int recursionMysteryMinus(int x, int y) {
    if (x < y) {
        return x;
    } else {
        return recursionMysteryMinus(x - y, y);
    }
}

(Side note: What is the function 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.