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.
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
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
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..8191
- Rémy Sigrist, PARI program
- Index entries for sequences that are permutations of the natural numbers
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
Comments