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.

Previous Showing 11-20 of 45 results. Next

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

Original entry on oeis.org

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
Offset: 0

Views

Author

Keywords

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

Examples

			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
		

References

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

Crossrefs

Equals A030547(n) - 1.
Cf. A065198, A065199 (record indices & values).

Programs

  • 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 *)
  • 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
    
  • Python
    A033665 = lambda n, LIM=333: next((i for i in range(LIM) if is_A002113(n) or not(n := A004086(n)+n)), -1) # The second, optional argument is a search limit, see above. - M. F. Hasler, May 23 2024

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

A063048 Numbers n such that the Reverse and Add! trajectory of n (presumably) does not reach a palindrome and does not join the trajectory of any term m < n.

Original entry on oeis.org

196, 879, 1997, 7059, 10553, 10563, 10577, 10583, 10585, 10638, 10663, 10668, 10697, 10715, 10728, 10735, 10746, 10748, 10783, 10785, 10787, 10788, 10877, 10883, 10963, 10965, 10969, 10977, 10983, 10985, 12797, 12898, 13097, 13197, 13694
Offset: 1

Views

Author

Klaus Brockhaus, Jul 07 2001, revised Nov 04 2003

Keywords

Comments

The starting number n is regarded as part of the trajectory, so palindromes are excluded from the sequence. A088753 is obtained if palindromes are not excluded. The smallest term in A063048 but not in A088753 is 19098, the smallest term in A088753 but not in A063048 is 9999.
Subsequence of A023108. Sequence A070788 is similarly defined, but palindromes are irrelevant. Corresponding sequences for other bases are A075252 (base 2), A077405 (base 3), A075421 (base 4).
If the trajectory of a number k joins the trajectory of a smaller number which is a term of the present sequence, then this occurs after very few Reverse and Add! steps (at most 8 for k < 100000, at most 10 for k < 1000000). On the other hand, the trajectories of the terms < 14000 do not join the trajectory of any smaller term within at least 1500 steps. This is the precise meaning of "presumably" in the definition.
The terms are rather unevenly distributed. They form clusters, especially above 10^4, 10^5, 10^6, ... . The interval from 10000 to 11000 for example contains 26 terms, whereas only two terms occur in the interval from 90000 to 100000.
It seems that if the most significant digit is not equal to 1, the least significant digit is always 9, while this does not hold for the Lychrel numbers as in A023108. - A.H.M. Smeets, Feb 18 2019
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".
The plot log_10(a(n)) versus log_10(n) shows a stepwise behavior. However, the global behavior seems to be a straight line with slope e/(e-1) (= A185393). This slope is also obtained for the seeds in the Reverse and Add! problem in other bases. (End)

Examples

			1997 is a term since the trajectory of 1997 (presumably) does not lead to a number which occurs in the trajectory of 196 or of 879 (actually checked for the first 10000 terms of these trajectories). The trajectory of 1997 joins the trajectory of 106 at 97768 (cf. A070796), but 106 is not a term of the present sequence.
		

References

  • Daniel Lignon, Dictionnaire de (presque) tous les nombres entiers, Ellipses, Paris, 2012, 702 pages. See Entry 196.

Crossrefs

Programs

  • Mathematica
    limit = 10^3; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    utraj = {};
    Select[Range[0, 14000], (x = NestWhileList[ # + IntegerReverse[#] &, #, ! PalindromeQ[#] &, 1, limit];
       If[Length[x] >= limit && Intersection[x, utraj] == {},
        utraj = Union[utraj, x]; True,
    utraj = Union[utraj, x]]) &] (* Robert Price, Oct 16 2019 *)

A058042 Trajectory of binary number 10110 under the operation 'Reverse and Add!' carried out in base 2.

Original entry on oeis.org

10110, 100011, 1010100, 1101001, 10110100, 11100001, 101101000, 110010101, 1011101000, 1101000101, 10111010000, 11000101101, 101111010000, 110010001101, 1011110100000, 1100001011101, 10111110100000
Offset: 0

Views

Author

N. J. A. Sloane, May 18 2001

Keywords

Comments

According to J. Walker, Ronald Sprague has proved that this trajectory does not contain a palindrome. [I would like a reference for this.] Another proof has been given by Klaus Brockhaus.
10110 is the smallest number with this property in base 2. The analogous number in base 10 is believed to be 196, but its trajectory (see A006960) has never been proved not to contain a palindrome.
The binary numbers have a regular pattern with cycle length 4:
a(4k) = 101^(k+1)010^(k+1) for k >= 1,
a(4k+1) = 1101^(k-1)0001^(k-1)01 for k >= 2,
a(4k+2) = 101^(k+1)010^(k+2) for k >= 0,
a(4k+3) = 110^(k+1)101^(k)01 for k >= 1, where ^ stands for repeated concatenation. - A.H.M. Smeets, Feb 03 2019
From A.H.M. Smeets, Feb 11 2019: (Start)
Pattern with cycle length 4 represented by contextfree grammars with production rules:
S_a -> 10 T_a 00, T_a -> 1 T_a 0 | 1101;
S_b -> 11 T_b 01, T_b -> 0 T_b 1 | 1000;
S_c -> 10 T_c 000, T_c -> 1 T_c 0 | 1101;
S_d -> 11 T_d 101, T_d -> 0 T_d 1 | 0010;
see also A058042 for similar grammars for the binary represented trajectory of 77. (End)

Crossrefs

See A061561 for the terms of A058042 written in base 10. Cf. A016016, A006960, A023108.

Programs

  • ARIBAS
    var m,c,rev: integer; end; m := 22; c := 1; bit_write(m); write(" "); rev := bit_reverse(m); while m <> rev and c < 25 do inc(c); m := m + rev; bit_write(m); write(" "); rev := bit_reverse(m); end;
    
  • Haskell
    a058042 = a007088 . a061561  -- Reinhard Zumkeller, Apr 21 2013
  • Mathematica
    Clear[a]; a[0] = 10110; a[n_] := a[n] = (m = IntegerDigits[ a[n-1] ]; m2 = FromDigits[m, 2]; IntegerDigits[ FromDigits[m // Reverse, 2] + m2, 2] // FromDigits); Table[a[n], {n, 0, 16}] (* Jean-François Alcover, Apr 03 2013 *)

Formula

a(n) = A007088(A061561(n)). - Reinhard Zumkeller, Apr 21 2013

Extensions

More terms from Klaus Brockhaus, May 27 2001

A001127 Trajectory of 1 under map x->x + (x-with-digits-reversed).

Original entry on oeis.org

1, 2, 4, 8, 16, 77, 154, 605, 1111, 2222, 4444, 8888, 17776, 85547, 160105, 661166, 1322332, 3654563, 7309126, 13528163, 49710694, 99312488, 187733887, 976071668, 1842242347, 9274664828, 17559329557, 93151725128, 175304440267, 937348843838, 1775697687577
Offset: 0

Views

Author

N. J. A. Sloane, Jun 05 2002

Keywords

Comments

Normally one stops as soon as a palindrome is reached.
A Reverse and Add! sequence.
Trajectories of 25, 34, 43, 52, 59, 61, 68, 70, 86, 95, ..., merge into this sequence. - Robert G. Wilson v, Dec 16 2005

Crossrefs

Programs

  • Haskell
    a001127 n = a001127_list !! n
    a001127_list = iterate a056964 1 -- Reinhard Zumkeller, Sep 22 2011
  • Maple
    a:= proc(n) option remember; `if`(n=0, 1, (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, Jun 18 2014
  • Mathematica
    NestList[ # + FromDigits@Reverse@IntegerDigits@# &, 1, 30] (* Robert G. Wilson v, Dec 16 2005 *)
    NestList[#+IntegerReverse[#]&,1,30] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Nov 19 2019 *)

A070788 Positive integers n such that the Reverse and Add! trajectory of n (presumably) does not join the trajectory of any m < n.

Original entry on oeis.org

1, 3, 5, 7, 9, 100, 102, 106, 108, 111, 112, 113, 114, 116, 117, 118, 119, 122, 124, 128, 133, 135, 137, 138, 166, 184, 186, 196, 199, 359, 399, 459, 539, 659, 679, 739, 759, 779, 799, 859, 879, 919, 939, 959, 979, 999, 1000, 1006, 1011, 1013, 1022, 1033, 1037
Offset: 1

Views

Author

Klaus Brockhaus, May 07 2002, revised Oct 15 2003

Keywords

Comments

The conjecture that the trajectories of the terms of this sequence do not join is based on the observation that if the trajectories of two integers below 10000 join, this happens after at most 15 steps, while for any two terms the trajectories do not join within 1200 steps. For pairs from 1, 3, 5, 7, 9, 100, 102, 106 this has even been checked for 10000 steps.
The positive integers are the domain of the equivalence relation 'the trajectories of a and b join'; each of its presumably infinitely many equivalence classes is represented by a term of this sequence. Each class contains infinitely many integers (cf. A070789 - A070798). In such a class the relation 'the trajectory of a is part of the trajectory of b' is a partial order for which a term c is a maximal element if it is in A067031 (integers not of the form k + reverse(k) for any k) and the integer at which the trajectories of a and b join is the greatest lower bound of a and b.

Examples

			The trajectory of 2 is part of the trajectory of 1; the trajectory of 3 does not join the trajectory of 1 within 10000 steps; the trajectory of 5 does not join the trajectory of 1 or of 3 within 10000 steps.
		

Crossrefs

Programs

  • Mathematica
    limit = 10^3; utraj = {};
    Select[Range[1037], (x = NestList[ # + IntegerReverse[#] &, #, limit]; If[Intersection[x, utraj] == {}, utraj = Union[utraj, x]; True, utraj = Union[utraj, x]]) &] (* Robert Price, Oct 20 2019 *)

A077594 Smallest number whose Reverse and Add! trajectory (presumably) contains exactly n palindromes, or -1 if there is no such number.

Original entry on oeis.org

196, 89, 49, 18, 9, 14, 7, 6, 3, 4, 2, 1, 10000, -1, -1, -1, -1, -1, -1, -1, -1
Offset: 0

Views

Author

Klaus Brockhaus, Nov 08 2002

Keywords

Comments

Conjecture 1: For each k > 0 the trajectory of k eventually leads to a term in the trajectory of some j which belongs to A063048, i.e. whose trajectory (presumably) never leads to a palindrome. Conjecture 2: There is no k > 0 such that the trajectory of k contains more than twelve palindromes, i.e. a(n) = -1 for n > 12.

Examples

			a(9) = 4 since the trajectory of 4 contains the nine palindromes 4, 8, 77, 1111, 2222, 4444, 8888, 661166, 3654563 and at 7309126 joins the trajectory of 10577 = A063048(6) and no m < 4 contains exactly nine palindromes.
		

Crossrefs

A063049 Integers n > 196 such that the 'Reverse and Add!' trajectory of n joins the trajectory of 196.

Original entry on oeis.org

295, 394, 493, 592, 689, 691, 788, 790, 887, 986, 1495, 1585, 1675, 1765, 1855, 1945, 2494, 2584, 2674, 2764, 2854, 2944, 3493, 3583, 3673, 3763, 3853, 3943, 4079, 4169, 4259, 4349, 4439, 4492, 4529, 4582, 4619, 4672, 4709, 4762, 4799, 4852, 4889, 4942
Offset: 1

Views

Author

Klaus Brockhaus, Jul 07 2001

Keywords

Comments

Subsequence of A023108.

Examples

			The trajectory of 394 reaches 887 in one step and 887 is a term in the trajectory of 196, so 394 belongs to the present sequence. The corresponding term in A063050, giving the number of steps, accordingly is 1.
		

References

  • Popular Computing (Calabasas, CA), The 196 Problem, Vol. 3 (No. 30, Sep 1975), page PC30-9. Gives initial terms of this sequence.

Crossrefs

Programs

  • Mathematica
    Block[{nn = 10^2, s}, s = NestList[# + IntegerReverse@ # &, 196, nn]; Rest@ Select[Range@ 5000, Length@NestWhileList[# + IntegerReverse@ # &, #, FreeQ[s, #] &, 1, nn] <= nn &]] (* Michael De Vlieger, Jan 21 2018 *)

Extensions

Offset corrected by Sean A. Irvine, Apr 17 2023

A072216 Consider the Reverse and Add! problem (cf. A001127); of all the n-digit numbers N which eventually reach a palindrome, pick that number N which takes the greatest number of steps to converge (in case of a tie, pick the smallest N); sequence gives values of N.

Original entry on oeis.org

5, 89, 187, 1297, 10911, 150296, 9008299, 15002893, 140669390, 1005499526, 10087799570
Offset: 1

Views

Author

N. J. A. Sloane, Jul 05 2002

Keywords

Comments

Since we do not even know if 196 eventually converges (see A006960, A023108) for n >= 3 these values are only conjectures.

Crossrefs

Extensions

Corrected and extended by Jason Doucette, May 20 2003; Oct 09 2005

A016016 Number of iterations of Reverse and Add which lead to a palindrome, or -1 if no palindrome is ever reached.

Original entry on oeis.org

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, 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, 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
Offset: 1

Views

Author

Keywords

Comments

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.
It is conjectured that a(196) = -1, see A023108.
Because A061563 has offset 0 one should add a(0) = 1 here. - Wolfdieter Lang, Jan 12 2018
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

Examples

			6 -> 6 + 6 = 12 -> 12 + 21 = 33 is palindromic, took 2 steps so a(6)=2.
n = 89 needs 24 steps to end up with the palindrome 8813200023188. See A240510. - _Wolfdieter Lang_, Jan 12 2018
		

Crossrefs

Programs

  • Mathematica
    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 *)
    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 *)
  • 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
    
  • 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

A033648 Trajectory of 3 under map x->x + (x-with-digits-reversed).

Original entry on oeis.org

3, 6, 12, 33, 66, 132, 363, 726, 1353, 4884, 9768, 18447, 92928, 175857, 934428, 1758867, 9447438, 17794887, 96644658, 182289327, 906271608, 1712444217, 8836886388, 17673772776, 85401510447, 159803020905, 668823329856, 1327746658722, 3606313135953, 7201626272016
Offset: 0

Views

Author

Keywords

Comments

Normally one stops as soon as a palindrome is reached.
A Reverse and Add! sequence.

Crossrefs

Programs

  • Haskell
    a033648 n = a033648_list !! n
    a033648_list = iterate a056964 3 -- Reinhard Zumkeller, Sep 22 2011
  • Maple
    a:= proc(n) option remember; `if`(n=0, 3, (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, Jun 18 2014
  • Mathematica
    NestList[ # + FromDigits@Reverse@IntegerDigits@# &, 3, 29] (* Robert G. Wilson v, Dec 16 2005 *)
Previous Showing 11-20 of 45 results. Next