login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A243112
a(n) is the smallest number that requires at least n adjacent bit swaps in order to pack all the ones to the right.
1
0, 2, 4, 8, 12, 20, 24, 40, 48, 56, 88, 104, 112, 176, 208, 224, 240, 368, 432, 464, 480, 736, 864, 928, 960, 992, 1504, 1760, 1888, 1952, 1984, 3008, 3520, 3776, 3904, 3968, 4032, 6080, 7104, 7616, 7872, 8000, 8064, 12160, 14208, 15232, 15744, 16000, 16128
OFFSET
0,2
COMMENTS
a(n) = i if and only if A055941(i) == n and A055941(j) < n for all j < i.
Indices where records of A055941 occur.
LINKS
PROG
(PARI) a055941(n) = {my(b=binary(n)); nb = 0; for (i=1, #b-1, if (b[i], nb += sum(j=i+1, #b, !b[j])); ); nb; }
lista(nn) = {vmax = 0; print1(vmax, ", "); for (n=1, nn, vnew = a055941(n); if (vnew > vmax, vmax = vnew; print1(n, ", "); ); ); } \\ Michel Marcus, Aug 29 2014
(Python)
A243112, a = [0], 0
for n in range(1, 2**30):
s = bin(n)[2:]
b = sum(s[i:].count('0') for i, d in enumerate(s, start=1) if d == '1')
if b > a:
A243112.append(n)
a = b # Chai Wah Wu, Sep 07 2014
CROSSREFS
Cf. A055941.
Sequence in context: A127405 A344932 A136034 * A230127 A059793 A118029
KEYWORD
nonn,base
AUTHOR
Philippe Beaudoin, Aug 20 2014
STATUS
approved