OFFSET
0,3
COMMENTS
Leading zeros in binary expansions are ignored.
This sequence is a self-inverse permutation of the nonnegative integers.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8191
Rémy Sigrist, PARI program
EXAMPLE
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
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jul 26 2024
STATUS
approved