n. Each step changes it in exactly one way:
- if the number is even, it is halved;
- if it is odd, 1 is subtracted from it.
How many steps does it take for the counter to reach 0?n=11 → 6
11 → 10 (odd, subtract 1) → 5 (halve) → 4 → 2 → 1 → 0. Six steps in total.
n=16 → 5
Halve four times (16 → 8 → 4 → 2 → 1), then subtract 1 once: 5 steps.
n=0 → 0
The number is already zero, so no steps are needed.
n=11
6
Run checks the first 3 tests in your browser. Submit checks all 48 tests on the server, hidden ones included.