For each call to the following method indicate what console
For each call to the following method, indicate what console output is produced: public void mystery2(int n) {if (n > 100) {System.out.print(n);} else {mystery2(2 * n); System.out.print(\", \" + n);}} mystery2(113); mystery2(70); mystery2(42); mystery2(30); mystery2(10);
Solution
What does this program do?
it prints the output of multipule of 2 of a given number, where it prints upto 100.
if the given number is greater then 100 prints the same.
example : if mystery2(2)
output: 128, 64, 32, 16, 8, 4, 2
mystery2(113)
output:
113
mystery2(70)
output:
140, 70
mystery2(42)
output:
168, 84, 42
mystery2(30)
output:
120, 60, 30
mystery2(10)
output:
160, 80, 40, 20, 10
