OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
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
KEYWORD
AUTHOR
Clark Kimberling, May 15 2025
STATUS
approved
