A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left.
For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output.
Numbers are always displayed without leading zeros.
Input: The first line continues integer t, the number of test cases and followed by t lines containing integers K.
Output:
For each K, output the smallest palindrome larger than K.
T=int(input("Enter the number of test cases: ")) while(T!=0): K=int(input("Enter a positive integer: ")) for i in range((K+1),1000000): digit=str(i) Rtemp=int(''.join(reversed(digit))) if Rtemp==i: print("The smallest palindrom larger than {} is {}\n".format(K,i)) #Basically the next palindrome number after K break T-=1
Output:
Enter the number of test cases: 2
Enter a positive integer: 808
The smallest palindrome larger than 808 is 818
Enter a positive integer: 2133
The smallest palindrome larger than 2133 is 2222
More Codes to Fcuk
- Alphabet pyramid
- Find prime numbers between lower and upper ranges
- Prime Factor
- Find the sum of positive even numbers
- An integer interval [a,b], Find the minimum size of a set S.
- Country A and B, how many years the population of A surpasses B.
- Identify pH level
- Find the Perfect Number
- Find out if a word is a palindrome or not
- Find next Palindrome of N number.
- The writing bot Question. A scientist has created a writing bot. Read and write activity needs to be captured.
- Total Number of Odds in the list
- Partition this string into as many parts as possible.
- Leap year
- LCM of two numbers
- Greatest of three numbers
- Find the Gravitational Force Acting Between Two Objects.
- Find the missing element in geometric progression
- Find the GCD Greatest common divisor
- convert a given float number to integer