191. Number of 1 Bits
题目:
https://leetcode.com/problems/number-of-1-bits/
难度:
Easy
转成二进制,数1的个数
class Solution(object):
def hammingWeight(self, n):
"""
:type n: int
:rtype: int
"""
count = 0
while n > 0:
count += n % 2
n = n//2
return count