A037853 Sum{d(i)-d(i-1): d(i)>d(i-1), i=1,...,m}, where Sum{d(i)*3^i: i=0,1,...,m} is base 3 representation of n.
0, 0, 1, 0, 0, 2, 1, 0, 1, 1, 1, 1, 0, 0, 2, 1, 0, 2, 2, 2, 2, 1, 1, 2, 1, 0, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1, 1, 1, 1, 0, 0, 2, 1, 0, 2, 2, 2, 2, 1, 1, 2, 1, 0, 2, 2, 2, 3, 2, 2, 4, 3, 2, 2, 2, 2, 2, 1, 1, 3, 2, 1, 2, 2, 2, 2, 1, 1, 2, 1, 0, 1, 1, 1, 2, 1, 1, 3, 2, 1, 2
Offset: 1
Links
- Clark Kimberling, Table of n, a(n) for n = 1..10000
Programs
-
Maple
A037853 := proc(n) a := 0 ; dgs := convert(n,base,3); for i from 2 to nops(dgs) do if op(i,dgs)>op(i-1,dgs) then a := a+op(i,dgs)-op(i-1,dgs) ; end if; end do: a ; end proc: # R. J. Mathar, Oct 16 2015
-
Mathematica
g[n_, b_] := Differences[IntegerDigits[n, b]]; b = 3; z = 120; Table[-Total[Select[g[n, b], # < 0 &]], {n, 1, z}]; (*A037853*) Table[Total[Select[g[n, b], # > 0 &]], {n, 1, z}]; (*A037844*) (* Clark Kimberling, Jan 18 2018 *)
Extensions
Definition corrected by R. J. Mathar, Oct 16 2015
Comments