# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a037879 Showing 1-1 of 1 %I A037879 #18 Feb 11 2019 01:42:23 %S A037879 0,0,0,0,1,0,0,0,1,1,1,0,1,0,0,0,1,1,2,1,1,1,1,0,1,1,1,0,1,0,0,0,1,1, %T A037879 2,1,2,2,2,1,1,1,2,1,1,1,1,0,1,1,2,1,1,1,1,0,1,1,1,0,1,0,0,0,1,1,2,1, %U A037879 2,2,3,1,2,2,2,2,2,2,2,1,1,1,2,1,2,2,2,1,1,1 %N A037879 a(n) = (1/2)*Sum{|d(i)-e(i)|} where Sum{d(i)*2^i} is the base-2 representation of n and {e(i)} are digits {d(i)} in nondecreasing order. %H A037879 Robert Israel, Table of n, a(n) for n = 1..10000 %F A037879 a(2*n) = a(n). a(2*n+1) is either a(n) or a(n) + 1. - _Robert Israel_, Feb 08 2019 %p A037879 A037879 := proc(n) %p A037879 local a,dgs,dgsE ; %p A037879 a := 0 ; %p A037879 dgs := convert(n,base,2); %p A037879 dgsE := sort(dgs) ; %p A037879 for i from 1 to nops(dgs) do %p A037879 a := a+ abs(op(i,dgs)-op(i,dgsE)) ; %p A037879 end do: %p A037879 a/2 ; %p A037879 end proc: # _R. J. Mathar_, Oct 19 2015 %K A037879 nonn,base %O A037879 1,19 %A A037879 _Clark Kimberling_ %E A037879 Definition swapped with A037870. - _R. J. Mathar_, Oct 19 2015 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE