OFFSET
1,12
COMMENTS
a(n) is also the minimum number of bit swap operations that needs to be performed to pack all the bits of n to the right. - Philippe Beaudoin, Aug 20 2014
The index of the k-th record of this sequence is A020522(k) and corresponds to k ones followed by k zeros. - Philippe Beaudoin, Aug 20 2014
LINKS
Philippe Beaudoin, Table of n, a(n) for n = 1..10000
MAPLE
a:= proc(n) local L, m;
L:= convert(n, base, 2);
m:= convert(L, `+`);
m - convert(L[1..m], `+`);
end proc:
seq(a(n), n=1..100); # Robert Israel, Aug 20 2014
PROG
(PARI) a(n) = {d = binary(n); e = vecsort(d); sum(i=1, #d, abs(d[i]-e[i]))/2; } \\ Michel Marcus, Aug 20 2014
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Definition swapped with A037879. - R. J. Mathar, Oct 19 2015
STATUS
approved