Skip to content

Instantly share code, notes, and snippets.

@shumon84
Created March 25, 2017 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shumon84/339a827715dac7a31bd147d75ee1157c to your computer and use it in GitHub Desktop.
Save shumon84/339a827715dac7a31bd147d75ee1157c to your computer and use it in GitHub Desktop.
int count_bits(int n)
{
int sum;
for(sum=0;n!=0;n&=n-1)
sum++;
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment