logo CodeStepByStep logo

recursionMystery9

Language/Type: Java recursion

For each call to the following recursive method, write the output that is produced as it would appear on the console.

public static int recursionMystery9(int x, int y) {
    if (x < 0) {
        return -recursionMystery9(-x, y);
    } else if (y < 0) {
        return -recursionMystery9(x, -y);
    } else if (x == 0 && y == 0) {
        return 0;
    } else {
        return 100 * recursionMystery9(x / 10, y / 10) + 10 * (x % 10) + y % 10;
    }
}
recursionMystery9(12, 49);
recursionMystery9(73, -8);
recursionMystery9(-248, -3795);

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.