login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A033665 Number of 'Reverse and Add' steps needed to reach a palindrome starting at n, or -1 if n never reaches a palindrome. 21

%I #69 May 21 2022 13:54:19

%S 0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,2,1,1,0,1,1,1,1,1,2,1,1,1,1,0,

%T 1,1,1,2,1,2,1,1,1,1,0,1,2,1,2,2,1,1,1,1,1,0,1,2,2,3,1,1,1,1,2,1,0,2,

%U 3,4,1,1,1,2,1,2,2,0,4,6,1,1,2,1,2,2,3,4,0,24,1,2,1,2,2,3,4,6,24,0,1,0,1,1

%N Number of 'Reverse and Add' steps needed to reach a palindrome starting at n, or -1 if n never reaches a palindrome.

%C Palindromes themselves are not 'Reverse and Add!'ed, so they yield a zero!

%C Numbers n that may have a(n) = -1 (i.e., potential Lychrel numbers) appear in A023108. - _Michael De Vlieger_, Jan 11 2018

%C Record indices and values are given in A065198 and A065199. - _M. F. Hasler_, Feb 16 2020

%D D. Wells, The Penguin Dictionary of Curious and Interesting Numbers Penguin Books, 1987, pp. 142-143.

%H Kerry Mitchell, <a href="/A033665/b033665.txt">Table of n, a(n) for n = 0..195</a>

%H P. De Geest, <a href="http://www.worldofnumbers.com/weblinks.htm">Some thematic websources</a>

%H Jason Doucette, <a href="http://www.jasondoucette.com/worldrecords.html#Most">World Records</a>

%H S. K. Eddins, <a href="https://web.archive.org/web/20091014155324/http://staff.imsa.edu:80/math/journal/volume4/articles/Palindrome.pdf">The Palindromic Order Of A Number</a> [archived page]

%H Kerry Mitchell, <a href="/A033665/a033665.txt">Table of n, a(n) for n = 0..10000</a> (The -1 entries are only conjectural)

%H Kerry Mitchell, <a href="/A033665/a033665_1.txt">Table of n, a(n) for n = 0..100000</a> (The -1 entries are only conjectural)

%H I. Peter, <a href="https://web.archive.org/web/20110728141429/http://www.floot.demon.co.uk/palindromes.html">Search for the biggest numeric palindrome</a> [archived page]

%H T. Trotter, Jr., <a href="https://web.archive.org/web/20180129201104/http://www.trottermath.net/recurops/palndrom.html">Palindrome Power</a> [archived page]

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/196-Algorithm.html">196-Algorithm</a>.

%H <a href="/index/Res#RAA">Index entries for sequences related to Reverse and Add!</a>

%e 19 -> 19+91 = 110 -> 110+011 = 121 = palindrome, took 2 steps, so a(19)=2.

%e n = 89 needs 24 steps to end up with the palindrome 8813200023188. See A240510. - _Wolfdieter Lang_, Jan 12 2018

%t rev[n_]:=FromDigits[Reverse[IntegerDigits[n]]];radd[n_]:=n+rev[n];

%t pal[n_]:=If[n==rev[n],True,False];

%t raddN[n_]:=Length[NestWhileList[radd[#]&,n,pal[#]==False&]]-1;

%t raddN/@Range[0,195] (* _Ivan N. Ianakiev_, Aug 31 2015 *)

%t With[{nn = 10^3}, Array[-1 + Length@ NestWhileList[# + IntegerReverse@ # &, #, !PalindromeQ@ # &, 1, nn] /. k_ /; k == nn -> -1 &, 200]] (* _Michael De Vlieger_, Jan 11 2018 *)

%o (PARI) rev(n)={d=digits(n);p="";for(i=1,#d,p=concat(Str(d[i]),p));return(eval(p))}

%o a(n)=if(n==rev(n),return(0));for(k=1,10^3,i=n+rev(n);if(rev(i)==i,return(k));n=i)

%o n=0;while(n<100,print1(a(n),", ");n++) \\ _Derek Orr_, Jul 28 2014

%o (PARI) A033665(n,LIM=333)={-!for(i=0,LIM,my(r=A004086(n)); n==r&&return(i); n+=r)} \\ with {A004086(n)=fromdigits(Vecrev(digits(n)))}. The second optional arg is a search limit that could be taken smaller up to very large n, e.g., 99 for n < 10^9, 200 for n < 10^14, 250 for n < 10^18: see A065199 for the records and A065198 for the n's. - _M. F. Hasler_, Apr 13 2019, edited Feb 16 2020

%Y Cf. A002113, A023108, A023109, A033865, A006960, A016016, A063048, A240510.

%Y Equals A030547(n) - 1.

%Y Cf. A065198, A065199 (record indices & values).

%K nonn,base,easy

%O 0,20

%A _N. J. A. Sloane_

%E More terms from _Patrick De Geest_, Jun 15 1998

%E I truncated the b-file at n=195, since the value of a(196) is not presently known (cf. A006960). The old b-files are now a-files. - _N. J. A. Sloane_, May 09 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)