login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

(1/2)*Sum{|d(i)-e(i)|} where Sum{d(i)*4^i} is base 4 representation of n and e(i) are digits d(i) in nondecreasing order.
2

%I #11 Dec 30 2023 16:50:05

%S 0,0,0,0,0,1,2,0,0,0,1,0,0,0,0,0,1,2,3,0,0,1,2,1,1,1,2,2,2,2,2,0,1,2,

%T 3,0,0,1,2,0,0,0,1,1,1,1,1,0,1,2,3,0,0,1,2,0,0,0,1,0,0,0,0,0,1,2,3,1,

%U 1,2,3,2,2,3,4,3,3,4,5,0,1,2,3,0,0,1,2,1,1,2

%N (1/2)*Sum{|d(i)-e(i)|} where Sum{d(i)*4^i} is base 4 representation of n and e(i) are digits d(i) in nondecreasing order.

%p A037881 := proc(n)

%p local a,dgs,dgsE ;

%p a := 0 ;

%p dgs := convert(n,base,4);

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

%A _Clark Kimberling_

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