0
Q:

bit counting

// C++ program to demonstrate __builtin_popcount() 
#include <iostream> 
using namespace std; 
  
int main() 
{ 
    cout << __builtin_popcount(4) << endl; 
    cout << __builtin_popcount(15); 
  
    return 0; 
} 
1
countBits = (n) => n.toString(2).split("0").join("").length;
1

New to Communities?

Join the community