Question 7 : Identify Palindrome

Identify Palindrome

Today we will discuss InfyTQ Coding question that is Identify Palindrome that was asked in InfyTQ Coding question InfyTQ Advance Coding Section. We will see the Question description along with function description and the Test Cases along with there explanation.

You will find the solution of the problem which is asked for InfyTQ Coding question in various programming language. 

 

Problem Statement-: For a given positive number num, identify the palindrome formed by performing the following operations-

  • Add num and its reverse 
  • Check whether the sum is palindrome or not. If not, add the sum and its reverse and repeat the process until a palindrome is obtained 

For example: 

If original integer is 195, we get 9,339 as the resulting palindrome after the fourth addition: 

   195

+ 591

————–

   786

+ 687

————–

   1473

+ 3741

————–

   5214

+ 4125

———-

  9339

Input format: 

  • Read num from the standard input stream. 

Output format: 

  • Print the palindrome calculated to the standard output stream. 

Sample Test Cases

  • Sample Input 1
    124
  • Sample Output 1
    545
  • Explanation 1
    The sum of 124 and its reverse 421 is 545 which is a palindrome. 
  • Sample input 1
    4
  • Sample output 1
    8
  • Explanation 1
    The sum of 4 and its reverse 4 is 8 which is a palindrome.