Palindrome Number

Jun 20, 2016


```python

def isPalindrome(x): “”” :type x: int :rtype: bool “”” if x < 0 or x > 2147483647: return False else: if x < 10: #1 return True elif x < 100: #12 return x % 10 == x / 10 elif x < 1000: #123 return x % 10 == x / 100 elif x < 10000: #1234 return x % 10 == x / 1000 and (x / 10) % 10 == (x/100) % 10 elif x < 100000: #12345 return x % 10 == x / 10000 and (x / 10) % 10 == (x/1000) % 10 elif x < 1000000: #123456 return x % 10 == x / 100000 and (x / 10) % 10 == (x / 10000) % 10 and (x / 100) % 10 == (x / 1000) % 10 elif x < 10000000: #1234567 return x % 10 == x / 1000000 and (x/10)%10 == (x/100000) % 10 and (x / 100)%10 == (x/10000)%10 elif x < 100000000: #12345678 return x % 10 == x / 10000000 and (x/10)%10 == (x/1000000)%10 and (x/100)%10 == (x/100000)%10 and (x/1000)%10 == (x/10000)%10 elif x < 1000000000: return x % 10 == x / 100000000 and (x/10)%10 == (x/10000000)%10 and (x/100)%10 == (x/1000000)%10 and (x/1000)%10 == (x/100000)%10 else: return x % 10 == x / 1000000000 and (x/10)%10 == (x/100000000)%10 and (x/100)%10 == (x/10000000)%10 and (x/1000)%10 == (x/1000000)%10 and (x/10000)%10 == (x/100000)%10