Skip to content
CodeItRaw
Code Reading
/
Halving
Path
Play
Daily
Leaderboard
tr
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?
1
def
halvings
(n):
2
count =
0
3
while
n >
1
:
4
n //=
2
5
count +=
1
6
return
count