2021-03-12 MATH 3600 Reverse and Add

269 days ago by calkin

Reverse and add until palindrome

Take a number in base 10: if it is a palindrome, stop: otherwise reverse its digits, and add them.  If the result is a palindrome, stop. 

Otherwise, continue.

121 # is a palindrome so we stop 
       
121
121
572 + 275 
       
847
847
847+748 
       
1595
1595
1595+5951 
       
7546
7546
7546+6457 
       
14003
14003
14003+30041 
       
44044
44044
n=162 
       
digit_list=n.digits() 
       
m=0 for i in digit_list: m=m*10+i print m 
       
261
261
def reverse_n(n): digit_list=n.digits() m=0 for i in digit_list: m=m*10+i return(m) 
       
reverse_n(194) 
       
491
491
n=196 for j in srange(10): n=n+reverse_n(n) print(n) 
       
887
1675
7436
13783
52514
94039
187088
1067869
10755470
18211171
887
1675
7436
13783
52514
94039
187088
1067869
10755470
18211171

Questions to investigate:

\begin{enumerate}

\item Starting at $n$, do we eventually reach a palindrome?

\item Starting at $n$, how many iterations of reverse and add does it take to reach a palindrome?

\item For those numbers that do reach a palindrome, can we spot patterns?

\item For those numbers that don't reach a palindrome, how fast do they grow?

\item If we just iterate reverse and add, without worrying about palindromes, how big is the Nth iterate?

\item If we just iterate reverse and add, how many of the iterates we see are palindromes?

\item Can we extend this problem to numbers with decimal expansions?

\item If all of the digits in the number are less than 5 will it become a palindrome in a single step?

\item If a number reaches a palindrome, must it reach another palindrome?

\item In a given range, for the numbers which do reach a palindrome, what is the average number of steps?

\item In a given range, what proportion of numbers reach palindromes?

\item Do number theoretic properties of $n$ influence whether it reaches a palindrome?

\item For numbers that do reach palindromes multiple times, what is the distance between palindromes?

\item What happens if we change the operation to reverse and multiply?

\item If all digits are less than or equal to 4, we get a palindome.  Are there any other $n$ which give a palindrome in one step?

\end{enumerate}

n=1 for i in srange(20): n=n+reverse_n(n) print n 
       
2
4
8
16
77
154
605
1111
2222
4444
8888
17776
85547
160105
661166
1322332
3654563
7309126
13528163
49710694
2
4
8
16
77
154
605
1111
2222
4444
8888
17776
85547
160105
661166
1322332
3654563
7309126
13528163
49710694