A031248 a(n)=(# 1's)-(# 2's) in first n terms of A031235.
1, 0, 0, 0, 0, 1, 2, 3, 2, 3, 3, 4, 4, 5, 5, 4, 5, 4, 3, 2, 2, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 3, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10, 9, 10, 11, 11, 12, 13, 13, 14, 15, 15, 14, 15, 16, 15, 16, 15, 14
Offset: 1
Keywords
Programs
-
Mathematica
Accumulate[Which[#==1,1,#==2,-1,True,0]&/@(Reverse[IntegerDigits[ #,5]]&/@ Range[ 0,40]//Flatten)] (* Harvey P. Dale, Aug 02 2016 *)