Last active
March 18, 2016 18:54
-
-
Save mdk-aza/7d5adf070f2cc4226fd4 to your computer and use it in GitHub Desktop.
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
String.prototype.reverse = function () { | |
return this.split("").reverse().join(""); | |
}; | |
function calcPalindromicNumber(num) { | |
for (var i=num;; i++) { | |
if (i % 2 === 0) { | |
continue; | |
} | |
if (i.toString() === i.toString().reverse() && | |
i.toString(8) === i.toString(8).reverse() && | |
i.toString(2) === i.toString(2).reverse()) { | |
return i; | |
} | |
} | |
} | |
console.log(calcPalindromicNumber(9));//9 | |
console.log(calcPalindromicNumber(10));//585 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment