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.

A374990 Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, the concatenation of the binary expansions of n and a(n), in at least one way, is palindromic.

Original entry on oeis.org

0, 1, 5, 3, 9, 2, 11, 7, 17, 4, 21, 6, 19, 22, 23, 15, 33, 8, 41, 12, 37, 10, 13, 14, 35, 38, 43, 27, 39, 46, 47, 31, 65, 16, 81, 24, 73, 20, 25, 28, 69, 18, 85, 26, 77, 45, 29, 30, 67, 70, 83, 51, 75, 86, 91, 59, 71, 78, 87, 55, 79, 94, 95, 63, 129, 32, 161
Offset: 0

Views

Author

Rémy Sigrist, Jul 26 2024

Keywords

Comments

Leading zeros in binary expansions are ignored.
This sequence is a self-inverse permutation of the nonnegative integers.

Examples

			The first terms, in decimal and in binary, alongside an appropriate palindrome, are:
  n   a(n)  bin(n)  bin(a(n))  palindromes
  --  ----  ------  ---------  -----------
   0     0       0          0            0
   1     1       1          1           11
   2     5      10        101        10101
   3     3      11         11         1111
   4     9     100       1001      1001001
   5     2     101         10        10101
   6    11     110       1011      1101011
   7     7     111        111       111111
   8    17    1000      10001    100010001
   9     4    1001        100      1001001
  10    21    1010      10101    101010101
  11     6    1011        110      1101011
  12    19    1100      10011    110010011
		

Crossrefs

Programs

  • PARI
    \\ See Links section.
    
  • Python
    from itertools import count, islice
    def p(s): return s == s[::-1]
    def c(v, w): return p(v+w) or p(w+v)
    def agen(): # generator of terms
        mink, a = 0, set()
        for n in count(0):
            bn = bin(n)[2:]
            an = next(k for k in count(mink) if k not in a and c(bin(k)[2:], bn))
            yield an
            a.add(an)
            while mink in a: mink += 1
    print(list(islice(agen(), 70))) # Michael S. Branicky, Jul 28 2024