Skip to content

Instantly share code, notes, and snippets.

@sosoyososo
Last active December 23, 2015 10:19
Show Gist options
  • Save sosoyososo/6620803 to your computer and use it in GitHub Desktop.
Save sosoyososo/6620803 to your computer and use it in GitHub Desktop.
python:回文数字判断第二波
i = 1281854581821
def getReverse(base, num):
if num < 10:
return base*10 + num
return getReverse(base*10+num%10, num/10)
def getReverse1(num):
i = 0
while num:
i = i*10 + num%10
num /= 10
return i
def isPalindrome(num):
return num == getReverse(0, num)
print (isPalindrome(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment