`Python` 之判斷判斷回數

Python 之判斷判斷回數

def is_palindrome(n):
    sum = 0
    temp = n
    while temp // 10 > 0:
        quotient = temp // 10 # 商
        remainder = temp % 10 # 餘數
        temp = quotient
        sum = sum * 10 + remainder * 10
    sum += temp 
    return sum == n


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章