cp's OEIS Frontend

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.

Showing 1-10 of 32 results. Next

A065198 Indices of record high values in A033665, ignoring those numbers that are believed never to reach a palindrome.

Original entry on oeis.org

0, 10, 19, 59, 69, 79, 89, 10548, 10677, 10833, 10911, 147996, 150296, 1000689, 1005744, 1007601, 7008899, 9008299, 100239862, 140669390, 1005499526, 10000442119, 10000761554, 10000853648, 10000973037, 10031199494, 10087799570, 1000006412206, 1090604591930, 1600005969190, 100000090745299, 100120849299260, 10000043099946481, 10078083499399210, 10442000392399960
Offset: 1

Views

Author

Klaus Brockhaus, Oct 20 2001

Keywords

Comments

Integers like 196, for which a palindrome is supposedly never reached, are disregarded. A065199 gives the corresponding records.
a(39) <= N = 12000700000025339936491 for which A033665(N) = 288, found on April 26, 2019 according to Doucette's web site. - M. F. Hasler, Feb 16 2020
From A.H.M. Smeets, Sep 18 2021: (Start)
Let d_0 d_1 d_2 ... d_n be the decimal digits of an (n+1)-digit number.
All numbers in this sequence seem to satisfy the following condition:
d_0 = "1" or d_n = "9", and for all k, 0 < k < floor((n-1)/2), d_k = "0" or d_k = "9" or d_(n-k) = "0" or d_(n-k) = "9".
As from this, N = 12000700000025339936491, does not seem to be a record-setting number in this sequence, i.e., there must exist a smaller number N with at least a delay of 288 to reach a palindromic number. (End)

Examples

			Starting with 89, 24 'Reverse and Add' steps are needed to reach a palindrome; starting with n < 89, fewer (at most 6, in fact) steps are needed. So 89 is a term.
		

Crossrefs

Programs

  • Mathematica
    limit = 10^3; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    best = -1; Select[Range[0, 1000], (np = #; i = 0;
       While[np != IntegerReverse[np] && i < limit,
        np = np + IntegerReverse[np]; i++];
    If[i >= limit, False, If[i > best, best = i; True]]) &] (* Robert Price, Oct 14 2019 *)
  • PARI
    my(m, M=-1); for(n=0,oo, if(MA033665(n, M+39), print1(n","); M=m)) \\ Only for illustration, not suitable for producing terms > 10^6, even with the custom search limit given as optional 2nd arg to A033665. - M. F. Hasler, Feb 16 2020

Extensions

Terms a(17) to a(21) from Sascha Kurz, Dec 05 2001
Terms a(22) ff. were taken from Jason Doucette, World records. - Klaus Brockhaus, Sep 24 2003
Offset changed to 1 by A.H.M. Smeets, Feb 14 2019
Edited by N. J. A. Sloane, Jul 16 2021

A065199 Record high values in A033665, ignoring those numbers that are believed never to reach a palindrome.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 24, 30, 53, 54, 55, 58, 64, 78, 79, 80, 82, 96, 97, 98, 109, 112, 113, 131, 135, 147, 149, 186, 187, 188, 198, 201, 232, 233, 236, 259, 260, 261
Offset: 1

Views

Author

Klaus Brockhaus, Oct 20 2001

Keywords

Comments

Records for the number of 'Reverse and Add' steps needed to reach a palindrome.
A065198 gives the corresponding starting points.

Examples

			Starting with 89, 24 'Reverse and Add' steps are needed to reach a palindrome; starting with n < 89, at most 6 steps are needed.
For n = A065198(21) = 1005499526, a(21) = 109 "reverse and add" operations are needed to reach a palindrome; for all smaller n, at most 98 steps are needed.
For n = A065198(31) ~ 10^14, a(31) = 198 "reverse and add" operations are needed to reach a palindrome; for all smaller n, at most 188 steps are needed.
For n = A065198(36) ~ 10^18, a(36) = 259 "reverse and add" operations are needed to reach a palindrome; for all smaller n, at most 236 steps are needed.
		

Crossrefs

Programs

  • Mathematica
    limit = 10^3; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    best = -1; lst = {};
    For[n = 0, n <= 100000, n++,
    np = n; i = 0;
    While[np != IntegerReverse[np] && i < limit,
      np = np + IntegerReverse[np]; i++];
    If[i < limit && i > best, best = i; AppendTo[lst, i]]]; lst (* Robert Price, Oct 14 2019 *)
  • PARI
    my(m, M=-1); for(n=0, oo, (MA033665(n, M+39))&&print1(M=m", ")) \\ For illustration; becomes very slow for terms > 70, even with the "custom" search limit as optional 2nd arg to A033665. - M. F. Hasler, Feb 16 2020

Formula

a(n) = A033665(A065198(n)). - M. F. Hasler, Feb 16 2020

Extensions

Terms a(17) to a(21) from Sascha Kurz, Dec 05 2001
Terms a(22) onwards were taken from Jason Doucette, World records. - Klaus Brockhaus, Sep 24 2003
Terms a(36) to a(38) were taken from Jason Doucette, World records and added by A.H.M. Smeets, Feb 10 2019
Edited by N. J. A. Sloane, Jul 16 2021

A002113 Palindromes in base 10.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515
Offset: 1

Views

Author

Keywords

Comments

n is a palindrome (i.e., a(k) = n for some k) if and only if n = A004086(n). - Reinhard Zumkeller, Mar 10 2002
It seems that if n*reversal(n) is in the sequence then n = 3 or all digits of n are less than 3. - Farideh Firoozbakht, Nov 02 2014
The position of a palindrome within the sequence can be determined almost without calculation: If the palindrome has an even number of digits, prepend a 1 to the front half of the palindrome's digits. If the number of digits is odd, prepend the value of front digit + 1 to the digits from position 2 ... central digit. Examples: 98766789 = a(19876), 515 = a(61), 8206028 = a(9206), 9230329 = a(10230). - Hugo Pfoertner, Aug 14 2015
This sequence is an additive basis of order at most 49, see Banks link. - Charles R Greathouse IV, Aug 23 2015
The order has been reduced from 49 to 3; see the Cilleruelo-Luca and Cilleruelo-Luca-Baxter links. - Jonathan Sondow, Nov 27 2017
See A262038 for the "next palindrome" and A261423 for the "preceding palindrome" functions. - M. F. Hasler, Sep 09 2015
The number of palindromes with d digits is 10 if d = 1, and otherwise it is 9 * 10^(floor((d - 1)/2)). - N. J. A. Sloane, Dec 06 2015
Sequence A033665 tells how many iterations of the Reverse-then-add function A056964 are needed to reach a palindrome; numbers for which this will never happen are Lychrel numbers (A088753) or rather Kin numbers (A023108). - M. F. Hasler, Apr 13 2019
This sequence is an additive basis of order 3, see Cilleruelo, Luca, & Baxter and Sigg. - Charles R Greathouse IV, Apr 08 2025

References

  • Karl G. Kröber, "Palindrome, Perioden und Chaoten: 66 Streifzüge durch die palindromischen Gefilde" (1997, Deutsch-Taschenbücher; Bd. 99) ISBN 3-8171-1522-9.
  • Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 71.
  • Alfred S. Posamentier, Math Charmers, Tantalizing Tidbits for the Mind, Prometheus Books, NY, 2003, pages 50-52.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See p. 120.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Subsequence of A061917 and A221221.
A110745 is a subsequence.
Union of A056524 and A056525.
Palindromes in bases 2 through 11: A006995 and A057148, A014190 and A118594, A014192 and A118595, A029952 and A118596, A029953 and A118597, A029954 and A118598, A029803 and A118599, A029955 and A118600, this sequence, A029956. Also A262065 (base 60), A262069 (subsequence).
Palindromic primes: A002385. Palindromic nonprimes: A032350.
Palindromic-pi: A136687.
Cf. A029742 (complement), A086862 (first differences).
Palindromic floor function: A261423, also A261424. Palindromic ceiling: A262038.
Cf. A004086 (read n backwards), A064834, A118031, A136522 (characteristic function), A178788.
Ways to write n as a sum of three palindromes: A261132, A261422.
Minimal number of palindromes that add to n using greedy algorithm: A088601.
Minimal number of palindromes that add to n: A261675.

Programs

  • GAP
    Filtered([0..550],n->ListOfDigits(n)=Reversed(ListOfDigits(n))); # Muniru A Asiru, Mar 08 2019
    
  • Haskell
    a002113 n = a002113_list !! (n-1)
      a002113_list = filter ((== 1) . a136522) [1..] -- Reinhard Zumkeller, Oct 09 2011
    
  • Haskell
    import Data.List.Ordered (union)
      a002113_list = union a056524_list a056525_list -- Reinhard Zumkeller, Jul 29 2015, Dec 28 2011
    
  • Magma
    [n: n in [0..600] | Intseq(n, 10) eq Reverse(Intseq(n, 10))]; // Vincenzo Librandi, Nov 03 2014
    
  • Maple
    read transforms; t0:=[]; for n from 0 to 2000 do if digrev(n) = n then t0:=[op(t0),n]; fi; od: t0;
    # Alternatively, to get all palindromes with <= N digits in the list "Res":
    N:=5;
    Res:= $0..9:
    for d from 2 to N do
      if d::even then
        m:= d/2;
        Res:= Res, seq(n*10^m + digrev(n),n=10^(m-1)..10^m-1);
      else
        m:= (d-1)/2;
        Res:= Res, seq(seq(n*10^(m+1)+y*10^m+digrev(n),y=0..9),n=10^(m-1)..10^m-1);
      fi
    od: Res:=[Res]: # Robert Israel, Aug 10 2014
    # A variant: Gets all base-10 palindromes with exactly d digits, in the list "Res"
    d:=4:
    if d=1 then Res:= [$0..9]:
    elif d::even then
        m:= d/2:
        Res:= [seq(n*10^m + digrev(n), n=10^(m-1)..10^m-1)]:
    else
        m:= (d-1)/2:
        Res:= [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:
    fi:
    Res; # N. J. A. Sloane, Oct 18 2015
    isA002113 := proc(n)
        simplify(digrev(n) = n) ;
    end proc: # R. J. Mathar, Sep 09 2015
  • Mathematica
    palQ[n_Integer, base_Integer] := Module[{idn = IntegerDigits[n, base]}, idn == Reverse[idn]]; (* then to generate any base-b sequence for 1 < b < 37, replace the 10 in the following instruction with b: *) Select[Range[0, 1000], palQ[#, 10] &]
    base10Pals = {0}; r = 2; Do[Do[AppendTo[base10Pals, n * 10^(IntegerLength[n] - 1) + FromDigits@Rest@Reverse@IntegerDigits[n]], {n, 10^(e - 1), 10^e - 1}]; Do[AppendTo[base10Pals, n * 10^IntegerLength[n] + FromDigits@Reverse@IntegerDigits[n]], {n, 10^(e - 1), 10^e - 1}], {e, r}]; base10Pals (* Arkadiusz Wesolowski, May 04 2012 *)
    nthPalindromeBase[n_, b_] := Block[{q = n + 1 - b^Floor[Log[b, n + 1 - b^Floor[Log[b, n/b]]]], c = Sum[Floor[Floor[n/((b + 1) b^(k - 1) - 1)]/(Floor[n/((b + 1) b^(k - 1) - 1)] - 1/b)] - Floor[Floor[n/(2 b^k - 1)]/(Floor[n/(2 b^k - 1)] - 1/ b)], {k, Floor[Log[b, n]]}]}, Mod[q, b] (b + 1)^c * b^Floor[Log[b, q]] + Sum[Floor[Mod[q, b^(k + 1)]/b^k] b^(Floor[Log[b, q]] - k) (b^(2 k + c) + 1), {k, Floor[Log[b, q]]}]] (* after the work of Eric A. Schmidt, works for all integer bases b > 2 *)
    Array[nthPalindromeBase[#, 10] &, 61, 0] (* please note that Schmidt uses a different, a more natural and intuitive offset, that of a(1) = 1. - Robert G. Wilson v, Sep 22 2014 and modified Nov 28 2014 *)
    Select[Range[10^3], PalindromeQ] (* Michael De Vlieger, Nov 27 2017 *)
    nLP[cn_Integer]:=Module[{s,len,half,left,pal,fdpal},s=IntegerDigits[cn]; len=Length[s]; half=Ceiling[len/2]; left=Take[s,half]; pal=Join[left,Reverse[ Take[left,Floor[len/2]]]]; fdpal=FromDigits[pal]; Which[cn==9,11,fdpal>cn,fdpal,True,left=IntegerDigits[ FromDigits[left]+1]; pal=Join[left,Reverse[Take[left,Floor[len/2]]]]; FromDigits[pal]]]; NestList[nLP,0,100] (* Harvey P. Dale, Dec 10 2024 *)
  • PARI
    is_A002113(n)=Vecrev(n=digits(n))==n \\ M. F. Hasler, Nov 17 2008, updated Apr 26 2014, Jun 19 2018
    
  • PARI
    is(n)=n=digits(n);for(i=1,#n\2,if(n[i]!=n[#n+1-i],return(0))); 1 \\ Charles R Greathouse IV, Jan 04 2013
    
  • PARI
    a(n)={my(d,i,r);r=vector(#digits(n-10^(#digits(n\11)))+#digits(n\11));n=n-10^(#digits(n\11));d=digits(n);for(i=1,#d,r[i]=d[i];r[#r+1-i]=d[i]);sum(i=1,#r,10^(#r-i)*r[i])} \\ David A. Corneth, Jun 06 2014
    
  • PARI
    \\ recursive--feed an element a(n) and it gives a(n+1)
    nxt(n)=my(d=digits(n));i=(#d+1)\2;while(i&&d[i]==9,d[i]=0;d[#d+1-i]=0;i--);if(i,d[i]++;d[#d+1-i]=d[i],d=vector(#d+1);d[1]=d[#d]=1);sum(i=1,#d,10^(#d-i)*d[i]) \\ David A. Corneth, Jun 06 2014
    
  • PARI
    \\ feed a(n), returns n.
    inv(n)={my(d=digits(n));q=ceil(#d/2);sum(i=1,q,10^(q-i)*d[i])+10^floor(#d/2)} \\ David A. Corneth, Jun 18 2014
    
  • PARI
    inv_A002113(P)={P\(P=10^(logint(P+!P,10)\/2))+P} \\ index n of palindrome P = a(n), much faster than above: no sum is needed. - M. F. Hasler, Sep 09 2018
    
  • PARI
    A002113(n,L=logint(n,10))=(n-=L=10^max(L-(n<11*10^(L-1)),0))*L+fromdigits(Vecrev(digits(if(nM. F. Hasler, Sep 11 2018
    
  • Python
    # edited by M. F. Hasler, Jun 19 2018
    def A002113_list(nMax):
      mlist=[]
      for n in range(nMax+1):
         mstr=str(n)
         if mstr==mstr[::-1]:
            mlist.append(n)
      return mlist # Bill McEachen, Dec 17 2010
    
  • Python
    from itertools import chain
    A002113 = sorted(chain(map(lambda x:int(str(x)+str(x)[::-1]),range(1,10**3)),map(lambda x:int(str(x)+str(x)[-2::-1]), range(10**3)))) # Chai Wah Wu, Aug 09 2014
    
  • Python
    from itertools import chain, count
    A002113 = chain(k for k in count(0) if str(k) == str(k)[::-1])
    print([next(A002113) for k in range(60)]) # Jan P. Hartkopf, Apr 10 2021
    
  • Python
    is_A002113 = lambda n: (s:=str(n))[::-1]==s # M. F. Hasler, May 23 2024
    
  • Python
    from math import log10, floor
    def A002113(n):
      if n < 2: return 0
      P = 10**floor(log10(n//2)); M = 11*P
      s = str(n - (P if n < M else M-P))
      return int(s + s[-2 if n < M else -1::-1]) # M. F. Hasler, Jun 06 2024
    
  • SageMath
    [n for n in (0..515) if Word(n.digits()).is_palindrome()] # Peter Luschny, Sep 13 2018
    
  • Scala
    def palQ(n: Int, b: Int = 10): Boolean = n - Integer.parseInt(n.toString.reverse) == 0
    (0 to 999).filter(palQ()) // _Alonso del Arte, Nov 10 2019

Formula

A136522(a(n)) = 1.
A178788(a(n)) = 0 for n > 9. - Reinhard Zumkeller, Jun 30 2010
A064834(a(n)) = 0. - Reinhard Zumkeller, Sep 18 2013
a(n+1) = A262038(a(n)+1). - M. F. Hasler, Sep 09 2015
Sum_{n>=2} 1/a(n) = A118031. - Amiram Eldar, Oct 17 2020
a(n) = (floor(d(n)/(c(n)*9 + 1)))*10^A055642(d(n)) + A004086(d(n)) where b(n, k) = ceiling(log((n + 1)/k)/log(10)), c(n) = b(n, 2) - b(n, 11) and d(n) = (n - A086573(b(n*(2 - c(n)), 2) - 1)/2 - 1). - Alan Michael Gómez Calderón, Mar 11 2025

A006960 Reverse and Add! sequence starting with 196.

Original entry on oeis.org

196, 887, 1675, 7436, 13783, 52514, 94039, 187088, 1067869, 10755470, 18211171, 35322452, 60744805, 111589511, 227574622, 454050344, 897100798, 1794102596, 8746117567, 16403234045, 70446464506, 130992928913, 450822227944, 900544455998, 1800098901007, 8801197801088, 17602285712176
Offset: 0

Views

Author

Keywords

Comments

196 is conjectured to be the smallest initial term which does not lead to a palindrome. John Walker, Tim Irvin and others have extended the trajectory of 196 to millions of digits without finding a palindrome.
From A.H.M. Smeets, Jan 31 2019: (Start)
Palindromes for a(9)/2, a(14)/2 and a(20)/2.
Observed: It seems that most, but not all, Lychrel numbers (seeds given in A063048) have a trajectory term that, divided by 2, becomes palindromic. Note that 196 is the first Lychrel number (A063048(1)). (End)
Observed: On average, 0.414 digits are gained by each step of the reverse and add procedure; i.e., 2.416 steps are needed on average to gain a factor of 10. This holds for any trajectory of reverse and add for decimal number representation. - A.H.M. Smeets, Feb 03 2019

Examples

			From _M. F. Hasler_, Apr 13 2019: (Start)
Start with 196 = a(0), then:
A056964(196) = 196 + 691 = 887 = a(1); then:
A056964(887) = 887 + 788 = 1675 = a(2); then:
A056964(1675) = 1675 + 5761 = 7436 = a(3); then:
A056964(7436) = 7436 + 6347 = 13783 = a(4); then:
A056964(13783) = 13783 + 38731 = 52514 = a(5); etc. (End)
		

References

  • J.-M. De Koninck, Ces nombres qui nous fascinent, Entry 196, p. 58, Ellipses, Paris 2008.
  • D. H. Lehmer, "Sujets d'étude. No. 74," Sphinx (Bruxelles), 8 (1938), 12-13. (This is the currently earliest known reference to the 196 Problem). - James D. Klein, Apr 09 2012
  • Daniel Lignon, Dictionnaire de (presque) tous les nombres entiers, Ellipses, Paris, 2012, 702 pages. See Entry 196.
  • Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 70.
  • Popular Computing (Calabasas, CA), The 196 Problem, Vol. 3 (No. 30, Sep 1975), pages PC30-6 to PC30-9.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a006960 n = a006960_list !! n
    a006960_list = iterate a056964 196 -- Reinhard Zumkeller, Sep 22 2011
    
  • Maple
    a:= proc(n) option remember; `if`(n=0, 196, (h-> h+ (s->
          parse(cat(s[-i]$i=1..length(s))))(""||h))(a(n-1)))
        end:
    seq(a(n), n=0..40);  # Alois P. Heinz, Jul 25 2014
  • Mathematica
    a = {196}; For[i = 2, i < 26, i++, a = Append[a, a[[i - 1]] + ToExpression[ StringReverse[ToString[a[[i - 1]]]]]]]; a
    NestList[#+FromDigits[Reverse[IntegerDigits[#]]]&,196,25] (* Harvey P. Dale, Jun 05 2011 *)
    NestList[#+IntegerReverse[#]&,196,25] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 04 2019 *)
  • PARI
    A006960_vec(N=99)=vector(N,i,N=if(i>1,A056964(N),196)) \\ M. F. Hasler, Apr 13 2019

Formula

a(n+1) = A056964(a(n)). - A.H.M. Smeets, Jan 27 2019

Extensions

More terms from Vit Planocka (planocka(AT)mistral.cz), Sep 28 2002

A033865 Start with n; if palindrome, stop; otherwise add to itself with digits reversed; a(n) gives palindrome at which it stops, or -1 if no palindrome is ever reached.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 33, 44, 55, 66, 77, 88, 99, 121, 22, 33, 22, 55, 66, 77, 88, 99, 121, 121, 33, 44, 55, 33, 77, 88, 99, 121, 121, 363, 44, 55, 66, 77, 44, 99, 121, 121, 363, 484, 55, 66, 77, 88, 99, 55, 121, 363, 484, 1111, 66, 77, 88, 99, 121, 121, 66, 484, 1111, 4884, 77, 88, 99, 121, 121, 363, 484, 77, 4884, 44044, 88
Offset: 0

Views

Author

Keywords

Comments

It is believed that a(196) = -1.

Examples

			19 -> 19 + 91 = 110 -> 110 + 011 = 121, so a(19) = 121.
		

References

  • M. Donner, I Love Me, Vol. I: S. Wordrow's palindromic encyclopedia (Algonquin Books, 1996) p. 268

Crossrefs

Cf. A061563, A016016, A023109, A006960, A023108, A002113, A033665 (number of steps).

Programs

  • ARIBAS
    var st: stack; end; for k := 0 to 60 do n := k; while n <> int_reverse(n) do n := n + int_reverse(n); end; stack_push(st,n); end; stack2array(st);
    
  • Mathematica
    Table[NestWhile[# + FromDigits[Reverse[IntegerDigits[#]]] &, n, IntegerDigits[#] != Reverse[IntegerDigits[#]] &], {n, 0, 90}] (* Harvey P. Dale, Dec 18 2011 *)
  • PARI
    a(n)=my(k); while((k=fromdigits(Vecrev(digits(n)))) != n, n += k); n \\ infinite loop if a(n) = -1; Charles R Greathouse IV, Dec 13 2015

Extensions

More terms from Jenise Smalley (neicey01(AT)hotmail.com), Oct 18 2001

A023109 a(0) = 0. For n > 0, smallest non-palindromic number k such that the smallest palindrome in the Reverse and Add! trajectory of k is reached after exactly n iterations.

Original entry on oeis.org

0, 10, 19, 59, 69, 166, 79, 188, 193, 1397, 829, 167, 2069, 1797, 849, 177, 1496, 739, 1798, 10777, 6999, 1297, 869, 187, 89, 10797, 10853, 10921, 10971, 13297, 10548, 13293, 17793, 20889, 700269, 106977, 108933, 80359, 13697, 10794, 15891, 1009227, 1007619, 1009246, 1008628, 600259, 131996, 70759, 1007377, 1001699, 600279, 141996, 70269, 10677, 10833, 10911
Offset: 0

Views

Author

Keywords

Comments

From Felix Fröhlich, May 28 2022: (Start)
Variant of A015994 not allowing palindromes as starting values.
Smallest non-palindromic k such that A033665(k) = n. (End)

Crossrefs

Programs

  • Mathematica
    Table[ SelectFirst[Range[0, 20000], (np = #; i = 0;
        While[ ! PalindromeQ[np] && i <= n, np = np + IntegerReverse[np];
         i++]; i == n ) &] , {n, 0, 32}] (* Robert Price, Oct 16 2019 *)
  • PARI
    rev(n)={d=digits(n);p="";for(i=1,#d,p=concat(Str(d[i]),p));return(eval(p))}
    nbs(n)=if(n==rev(n),return(0));for(k=1,10^3,i=n+rev(n);if(rev(i)==i,return(k));n=i) \\ A033665
    a(n)=for(k=1,10^8,if(nbs(k)==n,return(k)))
    n=0;while(n<100,print1(a(n),", ");n++) \\ Derek Orr, Jul 28 2014
    
  • PARI
    revadd(n) = n+eval(concat(Vecrev(Str(n))))
    iterationstosmallestpalindrome(n, bound) = my(x=n, i=0, d); while(1, if(i > bound, return(-1)); x=revadd(x); i++; d=digits(x); if(d==Vecrev(d), return(i)))
    a(n) = if(n==0, return(0)); for(k=1, oo, my(d=digits(k)); if(d!=Vecrev(d), if(iterationstosmallestpalindrome(k, n)==n, return(k)))) \\ Felix Fröhlich, May 28 2022
  • Python
    def A023109(n):
        if n > 0:
            k = 0
            while True:
                m = k
                for i in range(n):
                    if str(m) == str(m)[::-1]:
                        break
                    m += int(str(m)[::-1])
                else:
                    if str(m) == str(m)[::-1]:
                        return k
                k += 1
        else:
            return 0
    # Chai Wah Wu, Feb 08 2015
    

Extensions

a(41)-a(55) verified and added by Aldo González Lorenzo, May 15 2011
Name edited by Felix Fröhlich, May 28 2022

A072137 Length of the preperiodic part of the 'Reverse and Subtract' trajectory of n.

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 1, 2, 6, 4
Offset: 0

Views

Author

Klaus Brockhaus, Jun 24 2002

Keywords

Comments

'Reverse and Subtract' (cf. A070837, A070838) is defined by x -> |x - reverse(x)|, where reverse(x) is the digit reversal of x.
For every n the trajectory eventually becomes periodic, since 'Reverse and Subtract' does not increase the number of digits and so the set of available terms is finite. For small n the period length is 1, the periodic part consists of 0's, the last term of the preperiodic part is a palindrome.
The first n with period length 2 and a nontrivial periodic part is 1012 (cf. A072140).
This sequence is a weak analog of A033665, which uses 'Reverse and Add'.

Examples

			a(15) = 4 since 15 -> |15- 51| = 36 -> |36 - 63| = 27 -> |27 - 72| = 45 -> |45 - 54| = 9.
		

Crossrefs

Programs

  • Haskell
    import Data.List(inits, find); import Data.Maybe(fromJust)
    a072137 :: Int -> Int
    a072137 = length . fst . spanCycle (abs . a056965) where
       spanCycle :: Eq a => (a -> a) -> a -> ([a],[a])
       spanCycle f x = fromJust $ find (not . null . snd) $
                                  zipWith (span . (/=)) xs $ inits xs
                       where xs = iterate f x
    -- Reinhard Zumkeller, Oct 24 2010
  • Mathematica
    a[n_] := (k = 0; FixedPoint[ (k++; Abs[# - FromDigits[ Reverse[ IntegerDigits[#] ] ] ]) &, n]; k - 1); Table[ a[n], {n, 0, 104}] (* Jean-François Alcover, Dec 01 2011 *)

A066057 'Reverse and Add' carried out in base 2 (cf. A062128); number of steps needed to reach a palindrome, or -1 if no palindrome is ever reached.

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 2, 1, 0, 1, 0, 1, 4, 5, 0, -1, 2, 1, 4, -1, 0, -1, 2, 1, 0, 1, 0, 1, -1, 1, -1, 1, 2, 1, -1, 1, 2, 3, 0, -1, -1, 1, -1, 3, 0, 1, 2, 3, 2, 1, 2, 3, 2, -1, -1, 1, 0, 1, 0, 1, -1, 1, 2, 1, 4, 3, 0, 11, -1, 5, -1, -1, 2, 1, 2, 1, 4, -1, 0, -1, 2, 5, -1, -1, 2, 3, 0, -1, -1, 1, -1, 3, 0, 1, 4, 1, 10, 11, -1, -1, 0, -1, 2, -1, 4
Offset: 0

Views

Author

Klaus Brockhaus, Dec 04 2001

Keywords

Comments

The analog of A033665 in base 2.

Examples

			10011 (19 in base 10) -> 10011 + 11001 = 101100 -> 101100 + 1101 = 111001 -> 111001 + 100111 = 1100000 -> 1100000 + 11 = 1100011 (palindrome) requires 4 steps, so a(19) = 4.
		

Crossrefs

Programs

  • ARIBAS
    function b2reverse(a: integer): integer; var n,i,rev: integer; begin n := bit_length(a); for i := 0 to n-1 do if bit_test(a,i) = 1 then rev := bit_set(rev,n-1-i); end; end; return rev; end; function a066057(mx,stop: integer); var c,k,m,rev: integer; begin for k := 0 to mx do c := 0; m := k; rev := b2reverse(m); while m <> rev and c < stop do inc(c); m := m + rev; rev := b2reverse(m); end; if c < stop then write(c); else write(-1); end; write(" "); end; end; a066057(120,300);
  • Mathematica
    limit = 10^4; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    Table[np = n; i = 0;
     While[np != IntegerReverse[np, 2] && i < limit,
      np = np + IntegerReverse[np, 2]; i++];
    If[i >= limit, -1, i], {n, 0, 111}] (* Robert Price, Oct 14 2019 *)

A070742 a(n) = index of the (presumably) last palindrome in the 'Reverse and Add' trajectory of n, or -1 if this number is not finite, or 0 if no palindrome exists.

Original entry on oeis.org

18, 17, 32, 16, 36, 31, 30, 15, 23, 35, 34, 30, 33, 29, 29, 14, 32, 22, 28, 34, 30, 33, 29, 29, 14, 32, 22, 28, 27, 30, 33, 29, 29, 14, 32, 22, 28, 27, 28, 33, 29, 29, 14, 32, 22, 28, 27, 28, 26, 29, 29, 14, 32, 22, 28, 27, 28, 26, 13, 29, 14, 32, 22, 28, 27, 28, 26, 13, 27
Offset: 1

Views

Author

Klaus Brockhaus, May 03 2002

Keywords

Comments

The computation of a trajectory was stopped, when within 1000 steps no further palindrome appeared. - A033665(n) + 1 is the index of the first palindrome in the 'Reverse and Add' trajectory of n.
Terms correct for at least 10000 steps after last palindrome. - Sean A. Irvine, Jun 11 2024

Examples

			6, 33, 66, 363, 4884, 8836886388, 47337877873374 are the seven palindromes in the trajectory of 6 and the next 1000 steps do not lead to another palindrome; 47337877873374 is the 31st term in the trajectory, so a(6) = 31.
		

Crossrefs

Programs

  • ARIBAS
    var st,nst: string; end; for k := 1 to 74 do n := k; j := 1; x := 0; c := 0; while c < 1000 do st := itoa(n); nst := ""; for i := 0 to length(st) - 1 do nst := concat(st[i],nst); end; rev := atoi(nst); if n = rev then c := 0; x := j; end; inc(c); n := n + rev; inc(j); end; write(x,"," ); end;

A065206 Numbers which need one 'Reverse and Add' step to reach a palindrome.

Original entry on oeis.org

10, 12, 13, 14, 15, 16, 17, 18, 20, 21, 23, 24, 25, 26, 27, 29, 30, 31, 32, 34, 35, 36, 38, 40, 41, 42, 43, 45, 47, 50, 51, 52, 53, 54, 56, 60, 61, 62, 63, 65, 70, 71, 72, 74, 80, 81, 83, 90, 92, 100, 102, 103, 104, 105, 106, 107, 108, 110, 112, 113, 114, 115, 116, 117
Offset: 1

Views

Author

Klaus Brockhaus, Oct 21 2001

Keywords

Comments

The number of steps starts at 0, so palindromes (A002113) are excluded.
Numbers k such that A033665(k) = 1. - Andrew Howroyd, Dec 05 2024

Crossrefs

Programs

  • ARIBAS
    function revadd_steps(k,stop: integer); var c,n,m,steps,rev: integer; begin n := 0; c := 0; while c < stop do m := n; rev := int_reverse(m); steps := 0; while steps < k and m <> rev do m := m + rev; rev := int_reverse(m); inc(steps); end; if steps = k and m = rev then write(n," "); inc(c); end; inc(n); end; end; revadd_steps(1,66).
    
  • Haskell
    a065206 n = a065206_list !! (n-1)
    a065206_list = filter ((== 1) . a136522 . a056964) a029742_list
    -- Reinhard Zumkeller, Oct 14 2011
    
  • Mathematica
    Select[Range[10,120],!PalindromeQ[#]&&PalindromeQ[#+IntegerReverse[#]]&] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jun 14 2017 *)
  • PARI
    isok(n,s=1)={for(k=0, s, my(r=fromdigits(Vecrev(digits(n)))); if(r==n, return(k==s)); n += r); 0} \\ Andrew Howroyd, Dec 05 2024

Extensions

Offset corrected by Harry J. Smith, Oct 13 2009
Showing 1-10 of 32 results. Next