题解 | #求int型正整数在内存中存储时1的个数#
求int型正整数在内存中存储时1的个数
http://www.nowcoder.com/practice/440f16e490a0404786865e99c6ad91c9
递归
def to2(x, n = 0):
if x%2 == 1:
n += 1
if x < 1:
print(n)
else:
to2(x//2, n)
to2(int(input())) 求int型正整数在内存中存储时1的个数
http://www.nowcoder.com/practice/440f16e490a0404786865e99c6ad91c9
递归
def to2(x, n = 0):
if x%2 == 1:
n += 1
if x < 1:
print(n)
else:
to2(x//2, n)
to2(int(input())) 相关推荐
坦荡的马来熊在人才库:点进来,差点眼瞎,不知道看哪