Recursive solution. Check if it is even or odd and divide it by 2, keep checking until it is 0

```
/**
* Complex: O(logn)
* Runtime: 156ms
* Tests: 600 test cases passed
* Rank: A
* Updated: 2015-06-11
*/
var hammingWeight = function(n) {
return n === 0 ? 0 : (n % 2) + hammingWeight(~~(n / 2));
};
```