login
Numbers whose binary representation contains a maximal set of nonconsecutive 1's.
1

%I #23 Oct 04 2021 18:15:25

%S 1,2,5,9,10,18,21,37,41,42,73,74,82,85,146,149,165,169,170,293,297,

%T 298,329,330,338,341,585,586,594,597,658,661,677,681,682,1170,1173,

%U 1189,1193,1194,1317,1321,1322,1353,1354,1362,1365,2341,2345,2346,2377,2378

%N Numbers whose binary representation contains a maximal set of nonconsecutive 1's.

%C These are the numbers that do not contain 11 and 000 in their binary representations (cf. A086638), and in addition do not have 00 as their two lowest-order bits.

%e 5 is in this sequence, because its binary representation 101 cannot have any more ones added (below its highest nonzero bit) while preserving the property of having no two consecutive 1's.

%e 4 is not in the sequence, because its binary representation 100 can be augmented to 101, producing another number in the sequence.

%o (Python)

%o def A348167():

%o x = -1

%o while True:

%o x = x + 1

%o if x & (x>>1): continue

%o if (x & 3) == 0: continue

%o negx = ~x

%o gaps = negx & (negx >> 1) & (negx >> 2)

%o if (gaps-1) & x != x: continue

%o yield x

%Y Subsequence of A003714 and A086638.

%K nonn,base

%O 1,2

%A _David Eppstein_, Oct 03 2021