Lychrel Numbers

September 1, 2015

Let r(n) be the function that reverses the digits of the number n, and let s(n) = n + r(n); for instance, r(281) = 182 and s(281) = 281 + 182 = 463. Repeatedly applying s to the result of s(n) frequently leads to a palindrome; for instance, starting with n = 281, s(281) = 463, s(463) = 827, s(827) = 1555, s(1555) = 7106, s(7106) = 13123, and s(13123) = 45254, which is a palindrome. There are some numbers, such as 196, that apparently don’t lead to palindromes; these numbers are called Lychrel numbers (A023108), and we say apparently because no one knows if there might be a palindrome if the computation is continued sufficiently far. It is conjectured that there are an infinite number of Lychrel numbers.

Your task is to write a function that determines if a number appears to be a Lychrel number and, if not, returns the chain of numbers that shows it is not. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.