Largest Palindrome
You are given an integer
The input contains a single integer
The output should be a single integer which is the largest palindrome that is less than the given input.
Given
N = 45.44 is the largest number which is a palindrome that is less than 45.
N = int(input())
palindrome = -1
# 11 - smallest palindrome
for i in range(11, N):
if i > palindrome and str(i)[::-1] == str(i):
palindrome = i
if palindrome == -1:
print('No palindrome')
else:
print(palindrome)
Comments
Leave a comment