fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int k=0, n;
  6. cin >> n;
  7. while (n > 0){
  8. k += (n % 2);
  9. n = n / 2;
  10. }
  11. cout << k;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4180KB
stdin
5
stdout
2