logo CodeStepByStep logo

loopMysteryExam5

Language/Type: Java while return

For each call of the method below, write the output that is printed as it would appear on the console.

public static void loopMysteryExam5(int x, int y) {
    int z = y;
    while (x % z == 0) {
        System.out.print("(" + x + " " + z + ") ");
        x = x - z;
        z++;
    }
    System.out.println("(" + x + " " + z + ") " + y);
}
loopMysteryExam5(12, 4);
loopMysteryExam5(14, 2);
loopMysteryExam5(27, 3);

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.