While Loop Simulation
Category: Simulation
Author: Marty Stepp
Book Chapter: 5.1
Problem: While Loop Simulation
For each call below to the following method, write the output that is produced, as it would appear on the console:
public static void whileMystery(int x, int y) {
int z = 0;
while (x % y != 0) {
x = x / y;
z++;
System.out.print(x + ", ");
}
System.out.println(z);
}
1) whileMystery(25, 2);
2) whileMystery(10345, 10);
3) whileMystery(63, 2);