class Solution {
public:
int hammingWeight(uint32_t n) {
if(n==0)return 0;
int ans=1;
while (n>2){
ans+=n%2;
n=n/2;
}
return ans;
}
};
class Solution(object):
def hammingWeight(self, n):
"""
:type n: int
:rtype: int
"""
if n is 0:return 0
res=1
while n>2:
res+=n%2
n/=2
return res