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
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,20
COMMENTS
Palindromes themselves are not 'Reverse and Add!'ed, so they yield a zero!
Numbers n that may have a(n) = -1 (i.e., potential Lychrel numbers) appear in A023108. - Michael De Vlieger, Jan 11 2018
Record indices and values are given in A065198 and A065199. - M. F. Hasler, Feb 16 2020
REFERENCES
D. Wells, The Penguin Dictionary of Curious and Interesting Numbers Penguin Books, 1987, pp. 142-143.
LINKS
Jason Doucette, World Records
S. K. Eddins, The Palindromic Order Of A Number [archived page]
Kerry Mitchell, Table of n, a(n) for n = 0..10000 (The -1 entries are only conjectural)
Kerry Mitchell, Table of n, a(n) for n = 0..100000 (The -1 entries are only conjectural)
T. Trotter, Jr., Palindrome Power [archived page]
Eric Weisstein's World of Mathematics, 196-Algorithm.
EXAMPLE
19 -> 19+91 = 110 -> 110+011 = 121 = palindrome, took 2 steps, so a(19)=2.
n = 89 needs 24 steps to end up with the palindrome 8813200023188. See A240510. - Wolfdieter Lang, Jan 12 2018
MATHEMATICA
rev[n_]:=FromDigits[Reverse[IntegerDigits[n]]]; radd[n_]:=n+rev[n];
pal[n_]:=If[n==rev[n], True, False];
raddN[n_]:=Length[NestWhileList[radd[#]&, n, pal[#]==False&]]-1;
raddN/@Range[0, 195] (* Ivan N. Ianakiev, Aug 31 2015 *)
With[{nn = 10^3}, Array[-1 + Length@ NestWhileList[# + IntegerReverse@ # &, #, !PalindromeQ@ # &, 1, nn] /. k_ /; k == nn -> -1 &, 200]] (* Michael De Vlieger, Jan 11 2018 *)
PROG
(PARI) rev(n)={d=digits(n); p=""; for(i=1, #d, p=concat(Str(d[i]), p)); return(eval(p))}
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)
n=0; while(n<100, print1(a(n), ", "); n++) \\ Derek Orr, Jul 28 2014
(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
CROSSREFS
Equals A030547(n) - 1.
Cf. A065198, A065199 (record indices & values).
Sequence in context: A336676 A135341 A344299 * A104234 A355905 A368183
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
More terms from Patrick De Geest, Jun 15 1998
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
STATUS
approved

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 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)