编写一个有效的程序,以整数的二进制表示形式计算1的数量。
例子 :
Input : n = 6
Output : 2
Binary representation of 6 is 110 and has 2 set bits
Input : n = 13
Output : 3
Binary representation of 11 is 1101 and has 3 set bits
📅  最后修改于: 2021-05-28 04:33:27             🧑  作者: Mango
编写一个有效的程序,以整数的二进制表示形式计算1的数量。
例子 :
Input : n = 6
Output : 2
Binary representation of 6 is 110 and has 2 set bits
Input : n = 13
Output : 3
Binary representation of 11 is 1101 and has 3 set bits