%I #11 Dec 30 2023 16:50:37
%S 0,0,0,0,0,0,0,0,1,2,3,4,5,0,0,0,1,2,3,4,0,0,0,0,1,2,3,0,0,0,0,0,1,2,
%T 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,2,3,4,5,6,0,0,1,2,3,4,5,1,1,1,2,3,4,
%U 5,2,2,2,2,3,4,5,3,3,3,3,3,4,5,4,4,4,4,4,4,5
%N a(n)=(1/2)*Sum{|d(i)-e(i)|} where Sum{d(i)*7^i} is the base 7 representation of n and e(i) are the digits d(i) in nondecreasing order.
%p A037884 := proc(n)
%p local a,dgs,dgsE ;
%p a := 0 ;
%p dgs := convert(n,base,7);
%p dgsE := sort(dgs) ;
%p for i from 1 to nops(dgs) do
%p a := a+ abs(op(i,dgs)-op(i,dgsE)) ;
%p end do:
%p a/2 ;
%p end proc: # _R. J. Mathar_, Oct 19 2015
%K nonn,base
%O 1,10
%A _Clark Kimberling_
%E Definition swapped with A037875. - _R. J. Mathar_, Oct 19 2015