logo CodeStepByStep logo

You are working on problem set: Unit 4 ( Pause)

recursionMystery5

Language/Type: Java 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? .

If something seems wrong with our site, please

Is there a problem? Contact us.