logo CodeStepByStep logo

LoopMysteryExam5

Language/Type: C# 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)
    {
        Console.Write("(" + x + " " + z + ") ");
        x = x - z;
        z++;
    }
    Console.WriteLine("(" + 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.