Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Created May 27, 2014 21:50
Show Gist options
  • Save jikeytang/1c2f1b8990cb1d75e0ba to your computer and use it in GitHub Desktop.
Save jikeytang/1c2f1b8990cb1d75e0ba to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140528-题目1
输入任意数字,求该数二进制表达中有多少个1。
例如:输入10,由于其二进制表示为1010,有两个1,因此输出2
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@karrynew
Copy link

(454500).toString(2).match(/1/g).length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment