A309119 a(n) is the number of 1's minus the number of 2's among the ternary representations of the integers in the interval [0..n].
0, 1, 0, 1, 3, 3, 2, 2, 0, 1, 3, 3, 5, 8, 9, 9, 10, 9, 8, 8, 6, 6, 7, 6, 4, 3, 0, 1, 3, 3, 5, 8, 9, 9, 10, 9, 11, 14, 15, 18, 22, 24, 25, 27, 27, 27, 28, 27, 28, 30, 30, 29, 29, 27, 26, 26, 24, 24, 25, 24, 22, 21, 18, 18, 19, 18, 19, 21, 21, 20, 20, 18, 16, 15
Offset: 0
Examples
The first terms, alongside the ternary expansion of n and the corresponding number of 1's and 2's, are: n a(n) ter(n) A062756(n) A081603(n) -- ---- ------ ---------- ---------- 0 0 0 0 0 1 1 1 1 0 2 0 2 0 1 3 1 10 1 0 4 3 11 2 0 5 3 12 1 1 6 2 20 0 1 7 2 21 1 1 8 0 22 0 2 9 1 100 1 0 10 3 101 2 0
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..6560
- Rémy Sigrist, Colored pinplot of the sequence for n = 0..3^7-1 (where the color denotes the contribution of the digits according to their position in the ternary expansion)
- Wikipedia, Blancmange curve
Programs
-
Mathematica
Accumulate[Table[Total[IntegerDigits[n,3]/.(2->-1)],{n,0,80}]] (* Harvey P. Dale, Jun 23 2020 *)
-
PARI
s = 0; for (n=0, 73, t = digits(n,3); print1 (s+=sum(i=1, #t, if (t[i]==1, +1, t[i]==2, -1, 0)) ", "))
Comments