📜  Java程序计算整数中的设置位

📅  最后修改于: 2022-05-13 01:58:09.324000             🧑  作者: Mango

Java程序计算整数中的设置位

编写一个高效的程序来计算整数二进制表示中 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

设置位