Problem related to loop


In line no 7 bhaiya has written “while(n>0)” which n bhaiya is talking about 13 n or binary n i.e 0’s and 1’s if each time n is considered to be 13 then how the loop will terminate and at the last of the loop we are not even incrementing or decrementing the value of n pls sort the looping issue

hello @vikash3303

no we are changing the value of n in each iteration of while loop.
check line 9.
there we r doing
n=n>>1 ; which is same as n=n/2
so on each iteration we are dividing n by 2.
for example if initial n is 13
then it will change to following numbers
13-> 6 (13/2) -> 3 ( 6/2) - > 1 (3/2 ) -> 0 (1/2)