%I #15 Oct 24 2015 11:44:58
%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,2,3,3,3,3,3,0,1,2,3,0,0,1,2,1,1,1
%N a(n) = Sum_{i=1..m, d(i)<d(i-1)} d(i-1)-d(i), where Sum_{i=0..m} d(i)*4^i is the base 4 representation of n.
%H Clark Kimberling, <a href="/A037845/b037845.txt">Table of n, a(n) for n = 1..10000</a>
%p A037845 := proc(n)
%p a := 0 ;
%p dgs := convert(n,base,4);
%p for i from 2 to nops(dgs) do
%p if op(i,dgs)<op(i-1,dgs) then
%p a := a-op(i,dgs)+op(i-1,dgs) ;
%p end if;
%p end do:
%p a ;
%p end proc: # _R. J. Mathar_, Oct 19 2015
%t d[n_] := d[n] = Differences[RealDigits[n, 4][[1]]]
%t Table[Total[Select[d[n], # > 0 &]], {n, 1, z}]; (* A037845 *)
%t -Table[Total[Select[d[n], # < 0 &]], {n, 1, z}]; (* A037854 *)
%t (* _Clark Kimberling_, Oct 20 2015 *)
%K nonn,base
%O 1,7
%A _Clark Kimberling_
%E Definition swapped with A037854. - _R. J. Mathar_, Oct 19 2015