题解 | #查找输入整数二进制中1的个数#
查找输入整数二进制中1的个数
http://www.nowcoder.com/practice/1b46eb4cf3fa49b9965ac3c2c1caf5ad
function fn(num){
var count = 0
while(num != 0){
if(num%2 == 1){
count++
num = Math.floor(num/2)
}else{
num = num/2
}
}
return count
}
while (line = readline()) {
console.log(fn(line))
}
莉莉丝游戏公司福利 606人发布