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