Skip to content

Instantly share code, notes, and snippets.

@mdk-aza
Last active March 18, 2016 19:19
Show Gist options
  • Save mdk-aza/1f5a36b508d32a333787 to your computer and use it in GitHub Desktop.
Save mdk-aza/1f5a36b508d32a333787 to your computer and use it in GitHub Desktop.
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