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

A066059 Integers such that the 'Reverse and Add!' algorithm in base 2 (cf. A062128) does not lead to a palindrome.

Original entry on oeis.org

22, 26, 28, 35, 37, 41, 46, 47, 49, 60, 61, 67, 75, 77, 78, 84, 86, 89, 90, 94, 95, 97, 105, 106, 108, 110, 116, 120, 122, 124, 125, 131, 135, 139, 141, 147, 149, 152, 155, 157, 158, 163, 164, 166, 169, 172, 174, 177, 180, 182, 185, 186, 190, 191, 193, 197, 199
Offset: 1

Views

Author

Klaus Brockhaus, Dec 04 2001

Keywords

Comments

The analog of A023108 in base 2.
It seems that for all these numbers it can be proven that they never reach a palindrome. For this it is sufficient to prove this for all seeds as given in A075252. As observed, for all numbers in A075252, lim_{n -> inf} t(n+1)/t(n) is 1 or 2 (1 for even n, 2 for odd n or reverse); i.e., lim_{n -> inf} t(n+2)/t(n) = 2, t(n) being the n-th term of the trajectory. - A.H.M. Smeets, Feb 10 2019

Crossrefs

Programs

  • ARIBAS
    : For function b2reverse see A066057; function a066059(mx,stop: integer); var k,c,m,rev: integer; begin for k := 1 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(k," "); end; end; end; a066059(210,300).
  • Mathematica
    limit = 10^4; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    Select[Range[200],
    Length@NestWhileList[# + IntegerReverse[#, 2] &, #, # !=
    IntegerReverse[#, 2]  &, 1, limit] == limit + 1 &] (* Robert Price, Oct 14 2019 *)

A066058 In base 2: smallest integer which requires n 'Reverse and Add' steps to reach a palindrome.

Original entry on oeis.org

0, 2, 11, 44, 19, 20, 275, 326, 259, 202, 103, 74, 1027, 1070, 1049, 1072, 1547, 1310, 1117, 794, 569, 398, 3083, 2154, 1177, 1064, 4697, 4264, 4443, 2678, 2169, 1422, 779, 3226, 1551, 1114, 1815, 1062, 4197, 3106, 8697, 7238, 16633, 12302, 6683
Offset: 0

Views

Author

Klaus Brockhaus, Dec 04 2001

Keywords

Comments

The analog of A023109 in base 2.

Examples

			11 is the smallest integer which requires two steps to reach a base 2 palindrome (cf. A066057), so a(2) = 11; written in base 10: 11 -> 11 + 13 = 24 -> 24 + 3 = 27; written in base 2: 1011 -> 1011 + 1101 = 11000 -> 11000 + 11 = 11011.
		

Crossrefs

Programs

  • ARIBAS
    (* For function b2reverse see A066057. *) function a066058(mx: integer); var k,m,n,rev,steps: integer; begin for k := 0 to mx do n := 0; steps := 0; m := n; rev := b2reverse(m); while not(steps = k and m = rev) do inc(n); m := n; rev := b2reverse(m); steps := 0; while steps < k and m <> rev do m := m + rev; rev := b2reverse(m); inc(steps); end; end; write(n,","); end; end; a066058(45);
    
  • Mathematica
    Table[ SelectFirst[Range[0, 20000], (np = #; i = 0;
        While[ np != IntegerReverse[np, 2] && i <= n,
         np = np + IntegerReverse[np, 2]; i++];
    i == n ) &] , {n, 0, 44}] (* Robert Price, Oct 16 2019 *)
  • Python
    def A066058(n):
        if n > 0:
            k = 0
            while True:
                m = k
                for i in range(n):
                    s1 = format(m,'b')
                    s2 = s1[::-1]
                    if s1 == s2:
                        break
                    m += int(s2,2)
                else:
                    s1 = format(m,'b')
                    if s1 == s1[::-1]:
                        return k
                k += 1
        else:
            return 0 # Chai Wah Wu, Jan 06 2015

A062128 In base 2: 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, 11, 11, 101, 101, 1001, 111, 1001, 1001, 1111, 11011, 1111, 11011, 10101, 1111, 10001, 10001, 11011, 1100011, 1100011, 10101, -1, 111111, 11011, 1100011, -1, 11011, -1, 111111, 101101, 11111, 100001, 100001, 110011, -1, 101101, -1, 111111, 1100011, 101101, -1, 111111, 1100011, 1100011
Offset: 0

Views

Author

Klaus Brockhaus, Jun 06 2001

Keywords

Comments

The analog of A033865 in base 2.

Examples

			23: 10111 -> 10111 + 11101 = 110100 -> 110100 + 1011 = 111111, so a(23) = 111111.
		

Crossrefs

Programs

  • ARIBAS
    stop := 500; for k := 0 to 60 do c := 0; m := k; rev := bit_reverse(m); while m <> rev and c < stop do inc(c); m := m + rev; rev := bit_reverse(m); end; if c < stop then bit_write(m); else write(-1); end; write(" "); end;
  • Mathematica
    limit = 10^4; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
    BaseForm[Table[np = n; i = 0;
      While[np != IntegerReverse[np, 2] && i < limit,
       np = np + IntegerReverse[np, 2]; i++];
    If[i >= limit, -1, np], {n, 0, 44}], 2] (* 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

A062131 A062129 written in base 10.

Original entry on oeis.org

0, 3, 3, 9, 5, 15, 9, 21, 9, 27, 15, 27, 15, 27, 21, 45, 17, 51, 27, 99, 99, 63, -1, 63, 27, 99, -1, 255, -1, 63, 45, 93, 33, 99, 51, -1, 45, -1, 63, 99, 45, -1, 63, 99, 99, -1, -1, -1, 51, -1, 255, 153, 63, 99, 255, 153, 63, 99, 255, 153, -1, -1, 93, 189, 65, 195, 99, -1, 85, 255, 119, 387, 255, 219, 13299, -1, 387, -1, -1, 219
Offset: 0

Views

Author

Klaus Brockhaus, Jun 06 2001

Keywords

Comments

Differs from A062130 only for those n, which are palindromes in base 2.

Examples

			23 -> 23 + 29 = 52 -> 52 + 11 = 63, so a(23) = 63.
		

Crossrefs

Programs

  • ARIBAS
    stop := 500; for k := 0 to 80 do c := 0; m := k; test := true; while test and c < stop do inc(c); m := m + bit_reverse(m); test := m <> bit_reverse(m); end; if c < stop then write(m); else write(-1); end; write(" "); end;
Showing 1-7 of 7 results.