Created
May 19, 2014 23:38
-
-
Save jikeytang/af48f858376454200fba to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140520-题目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
打印出1-10000之间的所有对称数(如121,1331,2442)。 | |
回复时注意加上下面这句话,才会有语法高亮或格式缩进。 | |
```javascript |
sunnylost
commented
May 21, 2014
var arr = [];
for(var i = 1; i <= 9; i++){
for(var j =0; j <=9; j ++){
if(i == j) {
arr.push(i*10 + j)
}
arr.push(i*100 + j*10 + i);
arr.push(i*1000 + j*100 + j*10 + i);
}
}
console.log( arr )
var get_symmetry_nums = function(nums){
var start = 11,
symmetry_nums = [];
do{
symmetry_nums.push(start);
start+=11;
console.log(start);
}while(start<=nums);
return symmetry_nums;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment