196-Algorithm

DOWNLOAD Mathematica Notebook

Take any positive integer of two digits or more, reverse the digits, and add to the original number. This is the operation of the reverse-then-add sequence. Now repeat the procedure with the sum so obtained until a palindromic number is obtained. This procedure quickly produces palindromic numbers for most integers. For example, starting with the number 5280 produces the sequence 5280, 6105, 11121, 23232. The end results of applying the algorithm to 1, 2, 3, ... are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 33, 44, 55, 66, 77, 88, 99, 121, ... (OEIS A033865). The value for 89 is especially large, being 8813200023188.

The first few numbers not known to produce palindromes, sometimes known as Lychrel numbers (VanLandingham), are 196, 295, 394, 493, 592, 689, 691, 788, 790, 879, 887, ... (OEIS A023108).

The numbers obtained by iteratively applying the algorithm to 196, the smallest such number, are 196, 887, 1675, 7436, 13783, ... (OEIS A006960), and no palindromic member of this sequence is known. The special number 196 therefore lends itself to the name of the reverse-then-add algorithm. In 1990, John Walker computed 2415836 iterations of the algorithm on 196 and obtained a number having 1000000 digits. This was extended in 1995 by Tim Irvin, who obtained a number having 2000000 digits. M. Sofroniou (pers. comm., Feb. 16, 2002) gave an efficient Wolfram Language implementation that has complexity O(k^2) for k steps, requiring approximately 10.6 hours on a 450 MHz Pentium II to compute 250000 iterations. Extrapolating the timing data suggests that approximately 42 days would be needed on this same machine to match Walker's 2415836 iterations.

The rec.puzzles archive incorrectly states that a 3924257-digit nonpalindromic number is obtained after 9480000 iterations. However, the correct resulting number is 3924578 digits long. As of May 1, 2006, it had been determined after 724756966 iterations that a resulting palindromic number would have more than 300 million digits (VanLandingham).

The number of terms a(n) in the iteration sequence required to produce a palindromic number from n (i.e., a(n)=1 for a palindromic number, a(n)=2 if a palindromic number is produced after a single iteration of the 196-algorithm, etc.) for n=1, 2, ... are 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 1, ... (OEIS A030547). The smallest numbers that require n=0, 1, 2, ... iterations to reach a palindrome are 0, 10, 19, 59, 69, 166, 79, 188, ... (OEIS A023109).

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.