While Loop Simulation For each call of the method below, write the output that i
ID: 3645445 • Letter: W
Question
While Loop SimulationFor each call of the method below, write the output that is printed:
public static void mystery(int i, int j) {
while (i != 0 && j != 0) {
i = i / j;
j = (j - 1) / 2;
System.out.print(i + " " + j + " ");
}
System.out.println(i);
9
}
Method Call Output
mystery(5, 0); _______________________________
mystery(3, 2); _______________________________
mystery(16, 5); _______________________________
mystery(80, 9); _______________________________
mystery(1600, 40); _______________________________
Explanation / Answer
mystery(5, 0); 5 mystery(3, 2); 1 0 1 mystery(16, 5); 3 2 1 0 1 mystery(80, 9); 8 4 2 1 2 0 2 mystery(1600, 40); 40 19 2 9 0 4 0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.