fork(1) download
  1. #include <stdio.h>
  2. int countBits(int x)
  3. {
  4. int n = 0;
  5. if (x) do n++;
  6. while(x=x&(x-1));
  7. return n;
  8. }
  9.  
  10. int main(void) {
  11. printf("%d\n", countBits(25));
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 5476KB
stdin
Standard input is empty
stdout
3