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

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

PHP程序来计算整数中的设置位

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

设置位