login
Irregular table T(n, k), n > 0, k = 1..A356148(n), read by rows; the n-th row contains, in ascending order, the distinct positive integers whose binary expansion appears as a substring in the binary expansion of n or its complement.
3

%I #11 Jul 31 2022 19:54:04

%S 1,1,2,1,3,1,2,3,4,1,2,5,1,2,3,6,1,3,7,1,2,3,4,7,8,1,2,3,4,6,9,1,2,5,

%T 10,1,2,3,4,5,11,1,2,3,4,6,12,1,2,3,5,6,13,1,2,3,6,7,14,1,3,7,15,1,2,

%U 3,4,7,8,15,16,1,2,3,4,6,7,8,14,17,1,2,3,4,5,6,9,13,18

%N Irregular table T(n, k), n > 0, k = 1..A356148(n), read by rows; the n-th row contains, in ascending order, the distinct positive integers whose binary expansion appears as a substring in the binary expansion of n or its complement.

%C Leading 0's in binary expansions are ignored.

%C The n-th contains the n-th row of A165416.

%H Rémy Sigrist, <a href="/A356149/b356149.txt">Table of n, a(n) for n = 1..26775</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F T(n, 1) = 1.

%F T(n, A356148(n)) = n.

%e Table T(n, k) begins:

%e 1;

%e 1, 2;

%e 1, 3;

%e 1, 2, 3, 4;

%e 1, 2, 5;

%e 1, 2, 3, 6;

%e 1, 3, 7;

%e 1, 2, 3, 4, 7, 8;

%e 1, 2, 3, 4, 6, 9;

%e 1, 2, 5, 10;

%e 1, 2, 3, 4, 5, 11;

%e 1, 2, 3, 4, 6, 12;

%e 1, 2, 3, 5, 6, 13;

%e 1, 2, 3, 6, 7, 14;

%e 1, 3, 7, 15;

%e 1, 2, 3, 4, 7, 8, 15, 16;

%e ...

%o (PARI) row(n) = { my (b=binary(n)); setbinop((i,j) -> my (s=fromdigits(b[i..j],2)); if (b[i], s, 2^(j-i+1)-1-s), [1..#b]) }

%o (Python)

%o def row(n):

%o N = n.bit_length()

%o c, s = ((1<<N)-1)^n, set()

%o for i in range(N):

%o for l in range(N-i):

%o mask = ((2<<l)-1) << i

%o s.add((mask&n) >> i)

%o s.add((mask&c) >> i)

%o return sorted(s - {0})

%o print([t for r in range(19) for t in row(r)]) # _Michael S. Branicky_, Jul 28 2022

%Y Cf. A165416, A356148, A356150.

%K nonn,base,tabf

%O 1,3

%A _Rémy Sigrist_, Jul 28 2022