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-5 of 5 results.

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

A066144 In base 2: n sets a new record for the number of 'Reverse and Add' steps needed to reach a palindrome starting with n.

Original entry on oeis.org

0, 2, 11, 19, 20, 74, 398, 779, 1062, 2329, 4189, 4280, 11278, 19962, 98318, 135137, 1051360, 1592930, 69226926, 4295054186, 4446008678, 17187271449, 18123849698
Offset: 1

Views

Author

Klaus Brockhaus, Dec 08 2001

Keywords

Comments

The analog of A065198 in base 2. Integers like 22, for which a palindrome is never reached (cf. A066059), are of course disregarded. A066145 gives the corresponding records.

Examples

			Starting with 74, 11 'Reverse and Add' steps are needed to reach a palindrome; starting with n < 74, less (at most 5) steps are needed.
		

Crossrefs

Record setting values in base b: A077406 (b=3), A075686 (b=4), A306599 (b=8), A065198 (b=10), A348571 (Zeckendorf).

Programs

  • Mathematica
    limit = 10^4; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    best = -1; Select[Range[0, 100000], (np = #; i = 0;
       While[np != IntegerReverse[np, 2] && i < limit,
        np = np + IntegerReverse[np, 2]; i++];
    If[i >= limit, False, If[i > best, best = i; True]]) &] (* Robert Price, Oct 14 2019 *)

Extensions

Offset corrected and a(19)-a(23) from A.H.M. Smeets, Apr 30 2022

A066145 In base 2, records for the number of 'Reverse and Add' steps needed to reach a palindrome.

Original entry on oeis.org

0, 1, 2, 4, 5, 11, 21, 32, 37, 46, 48, 49, 53, 89, 99, 142, 147, 273, 297, 345, 515, 550, 573
Offset: 1

Views

Author

Klaus Brockhaus, Dec 08 2001

Keywords

Comments

The analog of A065199 in base 2. A066144 gives the corresponding starting points.
Terms a(19..22) obtained by assuming that a(n+1) <= a(n) + 300. - A.H.M. Smeets, Apr 30 2022

Examples

			Starting with 74, 11 'Reverse and Add' steps are needed to reach a palindrome; starting with n < 74, at most 5 steps are needed.
		

Crossrefs

Record values in base b: A077407 (b=3), A075687 (b=4), A306600 (b=8), A065199 (b=10), A348572 (Zeckendorf).

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 <= 10000, n++,
    np = n; i = 0;
    While[np != IntegerReverse[np, 2] && i < limit,
      np = np + IntegerReverse[np, 2]; i++];
    If[i < limit && i > best, best = i; AppendTo[lst, i]]]; lst (* Robert Price, Oct 14 2019 *)

Extensions

Offset corrected and a(19)-a(23) by A.H.M. Smeets, Apr 30 2022

A077441 In base 4, smallest number that requires n Reverse and Add! steps to reach a palindrome.

Original entry on oeis.org

0, 4, 7, 26, 28, 127, 306, 348, 398, 301, 308, 203, 311, 783, 294, 350, 199, 296, 4268, 16595, 5326, 4253, 17399, 8235, 6189, 4270, 3107, 1270, 1532, 511, 67816, 65975, 24670, 12395, 4282, 3119, 28799, 16861, 18164, 66268, 45087, 71164, 309234
Offset: 0

Views

Author

Klaus Brockhaus, Nov 05 2002

Keywords

Comments

Base-4 analog of A066058 (base 2) and A023109 (base 10).

Examples

			7 is the smallest number which requires two steps to reach a base 4 palindrome (cf. A075685), so a(2) = 5; 7 (decimal) = 13 -> 13 + 31 = 110 -> 110 + 011 = 121 (palindrome) = 25 (decimal).
		

Crossrefs

Programs

  • PARI
    {m=46; v=[]; for(j=1,m+1,v=concat(v,-1)); mc=m+1; n=0; while(mc>0,a=-1; c=0; k=n; while(c0,d=divrem(q,4); q=d[1]; rev=4*rev+d[2]); if(k==rev,a=c; c=m+1,c++; k=k+rev)); if(0<=a&&a<=m,if(v[a+1]<0,v[a+1]=n; mc--; print1([a,n]))); n++); print(); for(j=1,m+1,print1(v[j],","))}
    
  • Python
    from gmpy2 import digits
    def A077441(n):
        if n > 0:
            k = 0
            while True:
                m = k
                for i in range(n):
                    s = digits(m,4)
                    if s == s[::-1]:
                        break
                    m += int(s[::-1],4)
                else:
                    s = digits(m,4)
                    if s == s[::-1]:
                        return k
                k += 1
        else:
            return 0 # Chai Wah Wu, Jan 17 2015

A077403 In base 3: smallest number that requires n Reverse and Add! steps to reach a palindrome.

Original entry on oeis.org

0, 3, 5, 15, 17, 263, 170, 509, 491, 322, 266, 222, 161, 494, 260, 106, 95, 78, 53, 2425, 1466, 9717, 59583, 38878, 38798, 33515, 39440, 32857, 37340, 238849, 177470, 60019, 59655, 178540, 124895, 59753, 179751, 1595576, 715615, 354605, 179575
Offset: 0

Views

Author

Klaus Brockhaus, Nov 05 2002

Keywords

Comments

Base 3 analog of A066058 (base 2), A077441 (base 4) and A023109 (base 10).

Examples

			5 is the smallest number which requires two steps to reach a base 3 palindrome (cf. A066057), so a(2) = 5; 5 (decimal) = 12 -> 12 + 21 = 110 -> 110 + 011 = 121 (palindrome) = 16 (decimal).
		

Crossrefs

Programs

  • ARIBAS
    var ar: array; end; m := 45; ar := alloc(array, m+1, -1); mc := m+1; n := 0; while mc > 0 do v := -1; c := 0; k := n; while c < m+1 do d := k; rev := 0; while d > 0 do rev := 3*rev+(d mod 3); d := d div 3; end; if k = rev then v := c; c := m+1; else inc(c); k := k+rev; end; end; if 0 <= v and v <= m then if ar[v] < 0 then ar[v] := n; dec(mc); write((v,n)); end; end; inc(n); end; writeln(); for j := 0 to m do write(ar[j],","); end;
Showing 1-5 of 5 results.