The OEIS is supported by the many generous donors to the OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 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]. 1
 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 (list; graph; refs; listen; history; text; internal format)
 OFFSET 0,5 COMMENTS This sequence has connections with a Takagi (or blancmange) curve. Let t be the real function defined over [0..1] as follows: - t(x) = 0 for x in [0..1/3], - t(x) = x - 1/3 for x in ]1/3..2/3], - t(x) = 1 - x for x in ]2/3..1]. Let g be the real function defined over [0..1] as follows: - g(x) = Sum_{k >= 0} t(x * 3^k)/3^k. The representation of n -> (n/3^k, a(n)/3^k) for n = 0..3^k converges to the representation of g over [0..1] as k tends to infinity. 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 FORMULA a(n) = Sum_{k = 0..n} (A062756(k) - A081603(k)). a(n) >= 0 with equality iff n = 3^k - 1 for some k >= 0 (A024023). a(3*k + 2) = 3*a(k) for any k >= 0. a(3^k + m) = a(m) + m + 1 for any k >= 0 and m = 0..3^k-1. a(2*3^k + m) = a(m) + 3^k - m - 1 for any k >= 0 and m = 0..3^k-1. EXAMPLE 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 MATHEMATICA Accumulate[Table[Total[IntegerDigits[n, 3]/.(2->-1)], {n, 0, 80}]] (* Harvey P. Dale, Jun 23 2020 *) PROG (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)) ", ")) CROSSREFS Cf. A024023, A062756, A081603. Sequence in context: A020862 A131589 A338113 * A308725 A202691 A328143 Adjacent sequences:  A309116 A309117 A309118 * A309120 A309121 A309122 KEYWORD nonn,look,base AUTHOR Rémy Sigrist, Jul 13 2019 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified August 10 07:57 EDT 2022. Contains 356036 sequences. (Running on oeis4.)