How is the complexity log n?

How is the complexity log n?

hi when all bits are 1 then u need to log of no of bits time,
what we are doing is checking the last bit of the number and if the last bit of the number is 1 then adding it to the answer and otherwise not adding it to the answer .
Any number n can be represented by logn + 1 bits .
In this method we are traversing every bit . Therefore we are traversing logn +1 bits so the time complexity of the first method is O(LogN) .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.