K Palindrome Integers

 Coding Problem Keys 

 K Palindrome Integers 

 Problem Statement 

The program accepts two integers N and K as the input. The program must print the first K palindrome integers greater than N as the output.

 Input Format 

The first line contains the value of N and K separated by a space.

 Output Format 

The first line contains K integers representing the first K palindrome integers greater than N.

 Boundary Condition(s) 

1 <= N <= 10
1 <= K <= 1000

 Example Input/Output 1 

 Input 

1221 5

 Output 

1331 1441 1551 1661 1771

 Explanation 

Here N = 1221 and K = 5.
The first 5 palindrome integers greater than 1221 are 1331, 1441, 1551, 1661 and 1771.
Hence the output is
1331 1441 1551 1661 1771

 Example Input/Output 2 

 Input 

658100 10

 Output 

658856 659956 660066 661166 662266 663366 664466 665566 666666 667766

 Max Execution Time Limit: 500 millisecs 

 Solution 

 Programming Language: Python 3 Language 

n,k=map(int,input().split())
count=0
while(count<k):
    n+=1
    if(str(n)[::-1]==str(n)):
        print(n,end=" ")
        count+=1

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Cut Down & Plant - Trees

Both Adjacent Elements - Odd or Even

Archery Game

Shortest Path in Tree

Sum of Digits - Largest Integer

Octal Equivalent of N