Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 304 Bytes

File metadata and controls

17 lines (13 loc) · 304 Bytes
int hammingWeight(uint32_t n) {
        
        int x=1,ans=0;;

        while(n)
        {
            if(n&x)
                ans++;

            n=n>>1;
        }
        return ans;
    }