def reverse_num(x):
"""将数字进行逆序"""
yy = 0
while x:
x, y = divmod(x, 10)
yy *= 10
yy += y
return yy
def check(x):
"""检测是否是回文"""
if x < 0:
return False
y = reverse_num(x)
return x == y
def reverse_check(x):
"""检测是否是非利克瑞尔数
只进行最多5次逆序
"""
xx = x
for i in range(5):
y = reverse_num(x)
if check(y):
print(f'{xx}经过{i}次逆序后值为:{y}')
return True
if x != y:
print(f'第{i+1}次逆序,原值为:{x};逆序值为:{y}')
x += y
return False
res = reverse_check(int(input('请输入一个数字:')))
print(res)