This site is supported by donations to The OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A037870 a(n) = (1/2)*Sum{|d(i)-e(i)|}, where Sum{d(i)*2^i} is base 2 representation of n and e(i) are digits d(i) in nonincreasing order, for i=0,1,...,m. 3
 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 3, 2, 2 (list; graph; refs; listen; history; text; internal format)
 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 a(n) = 0 if A243109(n) = n; 1 + a(A243109(n)) otherwise. - 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 Sequence in context: A033665 A104234 A321926 * A250205 A326017 A290307 Adjacent sequences:  A037867 A037868 A037869 * A037871 A037872 A037873 KEYWORD nonn,base AUTHOR EXTENSIONS Definition swapped with A037879. - R. J. Mathar, Oct 19 2015 STATUS approved

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

Last modified September 21 19:59 EDT 2019. Contains 327282 sequences. (Running on oeis4.)