Advertisement
STANAANDREY

lsd3 11

Oct 14th, 2022 (edited)
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. import math
  2.  
  3.  
  4. def pal(n):
  5.     digits = int(math.log10(n)) + 1
  6.  
  7.     if digits == 1 or n == 0:
  8.         return True
  9.  
  10.     last = n % 10
  11.     first = n // (10 ** (digits - 1))
  12.  
  13.     if first != last:
  14.         return False
  15.  
  16.     return pal((n // (10 ** (digits - 1))) % 10)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement