Counting set bits and optimization

we have to repeat the loop until (n > 0) so in the number 5 -> 101 and zero is present at the middle of the number so the loop may break .

@rahulparida933 no first its 101 then it will be 10 then 1 and then 0 as we are doing right shift(divide by 2).
i hope its cleared if yes dont forget to hit like and mark resolved :smiley:
if any doubt in the above ask me

@rahulparida933 is it clear why you opened again?

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.