Last active
December 23, 2015 10:19
-
-
Save sosoyososo/6620803 to your computer and use it in GitHub Desktop.
python:回文数字判断第二波
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
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