Last active
March 18, 2016 19:19
-
-
Save mdk-aza/1f5a36b508d32a333787 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
def calcPalindromicNumber(num) | |
i = num; | |
loop { | |
if i.to_s == i.to_s.reverse && | |
i.to_s(8) == i.to_s(8).reverse && | |
i.to_s(2) == i.to_s(2).reverse | |
return i | |
end | |
i+=1 | |
} | |
end | |
puts(calcPalindromicNumber(9)) #9 | |
puts(calcPalindromicNumber(10)) #585 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment