A364871 a(n) = B(n) - A(n), where A(1) = 0, B(1) = 1, and sequences A and B are the lexicographically earliest sequences that start with their respective first terms and contain no term whose binary expansion is the concatenation of any two earlier terms in that sequence.
1, 1, 0, 0, 3, -4, -2, -1, -1, 4, 3, 4, 8, 8, 11, 11, 11, 1, 2, -2, -1, -11, -11, -12, -12, -7, -8, -5, -1, -2, -2, 2, -2, 0, 0, 1, 3, 6, 9, 9, 14, 10, 12, 13, 15, 19, 21, 22, 22, 25, 25, 20, 17, 11, 13, 8, 10, 6, 6, 1, 0, 4, 4, 4, 9, 8, 8, 1, 1, 1, 1, -6, -12, -11, -15, -21, -18, -20
Offset: 1
Examples
Sequence A: 0, 1, 3, 4, 5, 14, 15, 16, 17, 18, 20, 21, 22, ... Sequence B: 1, 2, 3, 4, 8, 10, 13, 15, 16, 22, 23, 25, 30, ... {a(n)}: 1, 1, 0, 0, 3, -4, -2, -1, -1, 4, 3, 4, 8, ...
Links
- Attila Kiss, Table of n, a(n) for n = 1..17483.
- Attila Kiss, Picture of the first ~17000 terms.
- Attila Kiss, Java program to generate terms.
Programs
-
Mathematica
conc[x_, y_] := FromDigits[Flatten@IntegerDigits[{x, y}, 2], 2]; f[n_, m_] := f[n, m] = If[n == 1, m, Module[{k = f[n - 1, m] + 1, v = Array[f[#, m] &, n - 1], c}, c = conc @@@ Select[Tuples[v, {2}], UnsameQ @@ # &]; While[! FreeQ[c, k], k++]; k]]; a[n_] := f[n, 1] - f[n, 0]; Array[a, 80] (* Amiram Eldar, Sep 29 2023 *)
-
Python
from itertools import islice def g(s=0): # helper generator for sequences A (s=0) and B (s=1) cn, bins, concats = s, {bin(s)[2:]}, set() while True: yield cn while (bn:=bin(cn:=cn+1)[2:]) in concats: pass concats |= {bn+bi for bi in bins} | {bi+bn for bi in bins} bins.add(bn) def agen(): # generator of terms A, B = g(s=0), g(s=1) yield from (Bn - An for An, Bn in zip(A, B)) print(list(islice(agen(), 78))) # Michael S. Branicky, Nov 01 2023
Comments