Skip to content
Read the Big-O

Halving

The input is the number n itself. How many times does the loop run, and how does the time grow?
1def halvings(n):
2 count = 0
3 while n > 1:
4 n //= 2
5 count += 1
6 return count