This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A016016 #43 Feb 16 2025 08:32:33 %S A016016 1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1, %T A016016 1,1,2,1,2,1,1,1,1,1,1,2,1,2,2,1,1,1,1,1,2,1,2,2,3,1,1,1,1,2,1,2,2,3, %U A016016 4,1,1,1,2,1,2,2,3,4,6,1,1,2,1,2,2,3,4,6,24,1,2,1,2,2,3,4,6,24 %N A016016 Number of iterations of Reverse and Add which lead to a palindrome, or -1 if no palindrome is ever reached. %C A016016 A first 'Reverse and Add' operation is always made, even if the starting value n is already a palindrome, in contrast to the variant A033665. %C A016016 It is conjectured that a(196) = -1, see A023108. %C A016016 Because A061563 has offset 0 one should add a(0) = 1 here. - _Wolfdieter Lang_, Jan 12 2018 %C A016016 Record indices and values beyond a(1) = 1 and a(5) = 2 are given in A065198 and A065199: These refer to the variant A033665 (main entry with more up-to-date references), as can be seen from A065199(1..3) = (0, 1, 2) for A065198(1..3) = (0, 10, 19). But all larger records correspond to a non-palindromic index n, in which case a(n) = A033665(n). - _M. F. Hasler_, Feb 16 2020 %H A016016 T. D. Noe, <a href="/A016016/b016016.txt">Table of n, a(n) for n = 1..195</a> %H A016016 J. Walker, <a href="http://www.fourmilab.ch/documents/threeyears/threeyears.html">Three Years Of Computing: Final Report On The Palindrome Quest</a> %H A016016 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/196-Algorithm.html">196-Algorithm</a>. %H A016016 <a href="/index/Res#RAA">Index entries for sequences related to Reverse and Add!</a> %e A016016 6 -> 6 + 6 = 12 -> 12 + 21 = 33 is palindromic, took 2 steps so a(6)=2. %e A016016 n = 89 needs 24 steps to end up with the palindrome 8813200023188. See A240510. - _Wolfdieter Lang_, Jan 12 2018 %t A016016 tol = 1000; r[n_] := FromDigits[Reverse[IntegerDigits[n]]]; palQ[n_] := n == r[n]; ar[n_] := n + r[n]; Table[k = 0; If[palQ[n], n = ar[n]; k = 1]; While[! palQ[n] && k < tol, n = ar[n]; k++]; If[k == tol, k = -1]; k, {n, 98}] (* _Jayanta Basu_, Jul 11 2013 *) %t A016016 With[{nn = 10^3}, Array[-1 + Length@ NestWhileList[# + IntegerReverse@ # &, #, ! PalindromeQ@ # &, {2, 1}, 10^3] /. k_ /; k == nn -> -1 &, 200, 0]] (* _Michael De Vlieger_, Jan 11 2018 *) %o A016016 (PARI) a(n) = my(x=n, i=0); while(1, x=x+eval(concat(Vecrev(Str(x)))); i++; if(x==eval(concat(Vecrev(Str(x)))), return(i))) \\ _Felix Fröhlich_, Jan 12 2018 %o A016016 (PARI) A016016(n, LIM=exponent(n+1)*5)={-!for(i=0, LIM, my(r=A004086(n)); n==r&&i&&return(i); n+=r)} \\ with {A004086(n)=fromdigits(Vecrev(digits(n)))}. The second optional arg is a search limit, with default value chosen according to known records A065199 and indices A065198. - _M. F. Hasler_, Feb 16 2020 %Y A016016 Cf. A033665, A023109, A006960, A061563, A240510. %K A016016 nonn,base,nice %O A016016 1,5 %A A016016 _Robert G. Wilson v_