Question: Problem:01 The reverse and add method is simple: choose a number, reverse its digits and add it to the original. If the sum is not
Problem:01 The reverse and add method is simple: choose a number, reverse its digits and add it to the original. If the sum is not a palindrome ( which means, it is not the same number from left to right and right to left), repeat this procedure. 195 Initial Number 591 ----- 786 687 ----- For example: 1473 3741 ------- 5214 4125 ------- 9339 Resulting Palindrome In this particular case the palindrome 9339 appeared after the 4th addition. This method leads to palindromes in a few steps for almost all of the integers. But there are interesting exceptions. 196 is the first number for which no palindrome has been found. It is not proven though, that there is no such a palindrome.
You must write a program that gives the resulting palindrome and the number of iterations (additions) to compute the palindrome. You might assume that all tests data on this problem: will have an answer, will be computable with less than 1000 iterations (additions), will yield a palindrome that is not greater than 4,294,967,295. Input The first line will have a number N (0 now write a c++ program that state above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
