A030349 (# 1's)-(# 0's) in first n terms of A030341.
1, 1, 0, 1, 2, 3, 3, 4, 3, 3, 4, 4, 4, 4, 3, 2, 3, 4, 3, 4, 4, 3, 4, 3, 4, 5, 6, 7, 8, 8, 9, 10, 9, 9, 10, 11, 11, 12, 12, 12, 13, 12, 11, 11, 12, 11, 11, 11, 10, 10, 9, 10, 10, 11, 12, 12, 12, 13, 13, 12, 12, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 11
Offset: 1
Keywords
Programs
-
Mathematica
Accumulate[Which[#==1,1,#==0,-1,True,0]&/@Flatten[Table[Reverse[IntegerDigits[n,3]],{n,40}]]] (* Harvey P. Dale, Jul 25 2024 *)