This loop keeps halving n, rounding down:
count = 0
while n > 1:
n //= 2
count += 1
Implement count_halving_steps(n) so it returns the final value of count.
Example 1
Input:
count_halving_steps(8)
Output:
3
8 → 4 → 2 → 1 is 3 steps.
Example 2
Input:
count_halving_steps(1000)
Output:
9
1000 → 500 → 250 → 125 → 62 → 31 → 15 → 7 → 3 → 1 is 9 steps.
1 <= n <= 10**18No results yet
Run your code to check it against the examples, or submit to run every test.