Discuss / Python / 不用字符串

不用字符串

Topic source

青铜神裔

#1 Created at ... [Delete] [Delete and Lock User]

import math

def is_palindrome(n): length = int(math.log10(n))+1 while length > 1: l = 10**(length-1) if n//l != n%10: return False n = n%l//10 length -= 2 return True


  • 1

Reply