Created
July 28, 2014 23:43
-
-
Save jikeytang/2520829f1cf04f28fde6 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140729-题目1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
输出在一个范围内,所有2进制位为1的数。 | |
比如: | |
[0,2] -> 1 对应2进制 (1) | |
[1,3] -> 1,3 对应2进制 (1, 11) | |
[2,5] -> 3 对应2进制 (11) | |
PS: | |
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。 | |
```javascript | |
// you code | |
``` | |
2. 粘贴代码时请使用shift+tab,缩进前面的空白。 |
chriswenwu
commented
Jul 30, 2014
function a(min,max){
var arr = [];
while (min <= max) {
(/^1+$/g).test((min++).toString(2)) && arr.push(min - 1);
}
return arr;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment