Question DSA-BIT-0041
MediumWhat is the output of this code?
def bits(n):
c = 0
while n:
n &= n - 1
c += 1
return c
print(bits(29), bits(255), bits(1024))
- A.
4 8 1
- B.
4 7 1
- C.
Sign up free to see the answer and a step-by-step explanation.