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!)
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

%I #35 Oct 19 2015 14:30:14

%S 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,

%T 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,

%U 1,1,1,2,2,2,1,2,1,1,1,2,2,2,2,2,2,2,1,3,2,2

%N 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.

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

%C a(n) = 0 if A243109(n) = n; 1 + a(A243109(n)) otherwise. - _Philippe Beaudoin_, Aug 20 2014

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

%H Philippe Beaudoin, <a href="/A037870/b037870.txt">Table of n, a(n) for n = 1..10000</a>

%p a:= proc(n) local L,m;

%p L:= convert(n,base,2);

%p m:= convert(L,`+`);

%p m - convert(L[1..m],`+`);

%p end proc:

%p seq(a(n),n=1..100); # _Robert Israel_, Aug 20 2014

%o (PARI) a(n) = {d = binary(n); e = vecsort(d); sum(i=1, #d, abs(d[i]-e[i]))/2;} \\ _Michel Marcus_, Aug 20 2014

%K nonn,base

%O 1,12

%A _Clark Kimberling_

%E Definition swapped with A037879. - _R. J. Mathar_, Oct 19 2015

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 23 02:41 EDT 2024. Contains 371906 sequences. (Running on oeis4.)