Last active
August 29, 2015 14:12
-
-
Save simonmysun/3b2d95027091e327bca4 to your computer and use it in GitHub Desktop.
to test palindrome numbers in different bases.
This file contains 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
(function() { | |
var num = []; | |
var l = 0; | |
var r = 1000000; | |
var n = 32; | |
for(var i = 2; i < n; i ++ ) { | |
num[i] = 0; | |
} | |
for(var i = l; i < r; i ++ ) { | |
for(var j = 2; j < n; j ++ ) { | |
var flag = 1; | |
var s = i.toString(j); | |
for(var k = 0; (k <= Math.floor(s.length / 2)) && flag; k ++ ) { | |
if(s[k] !== s[s.length - k - 1]) { | |
flag = 0; | |
} | |
} | |
if(flag) { | |
num[j] ++ ; | |
} | |
} | |
} | |
for(var i = 2; i < n; i ++ ) { | |
console.log(num[i]); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment