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.

A230891 Working in base 2: a(0)=0, thereafter a(n+1) is the smallest number not already in the sequence such that the bits of a(n) and a(n+1) together can be rearranged to form a palindrome.

Original entry on oeis.org

0, 11, 1, 10, 100, 111, 1000, 101, 110, 1001, 1010, 1100, 1111, 10000, 1011, 1101, 1110, 10001, 10010, 10100, 10111, 11000, 11011, 11101, 11110, 100000, 10011, 10101, 10110, 11001, 11010, 11100, 11111, 100001, 100010, 100100, 100111, 101000, 101011, 101101, 101110, 110000, 110011, 110101, 110110, 111001
Offset: 0

Views

Author

N. J. A. Sloane, Nov 11 2013

Keywords

Comments

A binary version of A228407.
The palindrome must be a proper binary number, i.e. must begin with 1 (if it is > 0). Also, the union of the bits of a(n) and a(n+1) cannot contain both an odd number of 0's and an odd number of 1's.
Just as for A228407, we can ask: does every number appear? The answer is yes - see the Comments in A228407.

Crossrefs

Cf. A228407, A230892 (these numbers written in base 10).

Programs

  • Mathematica
    a[0] = 0; a[n_] := a[n] = Block[{k = 1, idm = IntegerDigits[ a[n - 1], 2], t = a@# & /@ Range[n - 1]}, Label[ start]; While[ MemberQ[t, k], k++]; While[ Select[ Permutations[ Join[idm, IntegerDigits[k, 2]]], #[[1]] != 0 && # == Reverse@# &] == {}, k++; Goto[start]]; k]; s = Array[a, 46, 0]; FromDigits@# & /@ IntegerDigits[s, 2] (* Robert G. Wilson v, Dec 31 2013 *)
  • Python
    from collections import Counter
    A230891_list, l, s, b = [0, 11], Counter('11'), 1, {3}
    for _ in range(30001):
        i = s
        while True:
            if i not in b:
                li, o = Counter(bin(i)[2:]), 0
                for d in (l+li).values():
                    if d % 2:
                        if o > 0:
                            break
                        o += 1
                else:
                    A230891_list.append(int(bin(i)[2:]))
                    l = li
                    b.add(i)
                    while s in b:
                        b.remove(s)
                        s += 1
                    break
            i += 1 # Chai Wah Wu, Jun 19 2016