Question PSC-LOOP-0017
HardWhat will be the output of the following pseudocode?
Integer n = 6, steps = 0
while (n != 1)
if (n mod 2 == 0)
n = n / 2
else
n = 3 * n + 1
end if
steps = steps + 1
end while
Print steps
- A.
9
- B.
16
- C.
Sign up free to see the answer and a step-by-step explanation.