Judgment of the number of times the entered numerical value (the numerical value that becomes the same even if the numerical values are arranged in reverse)
#Returns true if it is a palindromic number
def checkPalindromicNumber(number)
number = number.to_s
size = number.length / 2 - 1
return ( number[0..size] == number.reverse[0..size] )
end
↓ Modified version
def palindromic_number?(number)
number.to_s == number.to_s.reverse
end
Recommended Posts