login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

%I #23 Sep 08 2014 00:35:01

%S 0,2,4,8,12,20,24,40,48,56,88,104,112,176,208,224,240,368,432,464,480,

%T 736,864,928,960,992,1504,1760,1888,1952,1984,3008,3520,3776,3904,

%U 3968,4032,6080,7104,7616,7872,8000,8064,12160,14208,15232,15744,16000,16128

%N a(n) is the smallest number that requires at least n adjacent bit swaps in order to pack all the ones to the right.

%C a(n) = i if and only if A055941(i) == n and A055941(j) < n for all j < i.

%C Indices where records of A055941 occur.

%H Philippe Beaudoin, <a href="/A243112/b243112.txt">Table of n, a(n) for n = 0..132</a>

%o (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; }

%o 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

%o (Python)

%o A243112, a = [0], 0

%o for n in range(1,2**30):

%o ....s = bin(n)[2:]

%o ....b = sum(s[i:].count('0') for i,d in enumerate(s,start=1) if d == '1')

%o ....if b > a:

%o ........A243112.append(n)

%o ........a = b # _Chai Wah Wu_, Sep 07 2014

%Y Cf. A055941.

%K nonn,base

%O 0,2

%A _Philippe Beaudoin_, Aug 20 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 22:17 EDT 2024. Contains 371964 sequences. (Running on oeis4.)