login
A383669
Numbers whose binary representation has a positive number of 0's, all with odd runlength.
2
2, 5, 6, 8, 10, 11, 13, 14, 17, 21, 22, 23, 24, 26, 27, 29, 30, 32, 34, 35, 40, 42, 43, 45, 46, 47, 49, 53, 54, 55, 56, 58, 59, 61, 62, 65, 69, 70, 71, 81, 85, 86, 87, 88, 90, 91, 93, 94, 95, 96, 98, 99, 104, 106, 107, 109, 110, 111, 113, 117, 118, 119, 120
OFFSET
1,1
LINKS
EXAMPLE
The binary representation 40 is 101000, so 40 is in the sequence.
MAPLE
with(priqueue):
R:= NULL: count:= 0:
q:= 1:
initialize(pq);
insert([-1], pq);
while count < 100 do
t:= op(extract(pq));
if t = -q then q:= 2*q+1
else R:= R, -t; count:= count+1;
fi;
insert([2*t-1], pq);
if t::odd then insert([2*t], pq)
else insert([4*t], pq)
fi;
od:
R; # Robert Israel, Jun 16 2025
MATHEMATICA
Map[#[[1]] &, Cases[Map[{#, # =!= {} && Apply[And, OddQ[StringLength[#]]] &[StringCases[IntegerString[#, 2], "0" ..]]} &, Range[400]], {_, True}]] (* Peter J. C. Moses, Apr 23 2025 *)
PROG
(Python)
def ok(n): return n&(n+1) > 0 and all(run == '' or len(run) % 2 for run in bin(n)[2:].split('1'))
print([n for n in range(121) if ok(n)]) # David Radcliffe, Jun 16 2025
CROSSREFS
Sequence in context: A176590 A253061 A320730 * A087943 A034020 A395965
KEYWORD
nonn,look,base
AUTHOR
Clark Kimberling, May 15 2025
STATUS
approved