logo CodeStepByStep logo

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

recursionMysteryComma

Language/Type: Java recursion

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

public static void recursionMysteryComma(int x, int y) {
    if (y == 1) {
        System.out.print(x);
    } else {
        System.out.print((x * y) + ", ");
        recursionMysteryComma(x, y - 1);
        System.out.print(", " + (x * y));
    }
}
recursionMysteryComma(4, 1);
recursionMysteryComma(4, 2);
recursionMysteryComma(8, 2);
recursionMysteryComma(4, 3);
recursionMysteryComma(3, 4);

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.