Skip to content

Instantly share code, notes, and snippets.

@charlieInDen
Created October 22, 2020 19:14
Show Gist options
  • Save charlieInDen/29dd0531b1984c097eb59d2e47029609 to your computer and use it in GitHub Desktop.
Save charlieInDen/29dd0531b1984c097eb59d2e47029609 to your computer and use it in GitHub Desktop.
count bit
def count_bits(n):
count = 0
while n != 0 :
if n&1 :
count += 1
n = n >> 1
return count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment