cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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].

This page as a plain text file.
%I A309119 #17 Jun 23 2020 13:08:50
%S A309119 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,
%T A309119 10,9,11,14,15,18,22,24,25,27,27,27,28,27,28,30,30,29,29,27,26,26,24,
%U A309119 24,25,24,22,21,18,18,19,18,19,21,21,20,20,18,16,15
%N 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].
%C A309119 This sequence has connections with a Takagi (or blancmange) curve.
%C A309119 Let t be the real function defined over [0..1] as follows:
%C A309119 - t(x) = 0 for x in [0..1/3],
%C A309119 - t(x) = x - 1/3 for x in ]1/3..2/3],
%C A309119 - t(x) = 1 - x for x in ]2/3..1].
%C A309119 Let g be the real function defined over [0..1] as follows:
%C A309119 - g(x) = Sum_{k >= 0} t(x * 3^k)/3^k.
%C A309119 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.
%H A309119 Rémy Sigrist, <a href="/A309119/b309119.txt">Table of n, a(n) for n = 0..6560</a>
%H A309119 Rémy Sigrist, <a href="/A309119/a309119.png">Colored pinplot of the sequence for n = 0..3^7-1</a> (where the color denotes the contribution of the digits according to their position in the ternary expansion)
%H A309119 Wikipedia, <a href="https://en.wikipedia.org/wiki/Blancmange_curve">Blancmange curve</a>
%F A309119 a(n) = Sum_{k = 0..n} (A062756(k) - A081603(k)).
%F A309119 a(n) >= 0 with equality iff n = 3^k - 1 for some k >= 0 (A024023).
%F A309119 a(3*k + 2) = 3*a(k) for any k >= 0.
%F A309119 a(3^k + m) = a(m) + m + 1 for any k >= 0 and m = 0..3^k-1.
%F A309119 a(2*3^k + m) = a(m) + 3^k - m - 1 for any k >= 0 and m = 0..3^k-1.
%e A309119 The first terms, alongside the ternary expansion of n and the corresponding number of 1's and 2's, are:
%e A309119   n   a(n)  ter(n)  A062756(n)  A081603(n)
%e A309119   --  ----  ------  ----------  ----------
%e A309119    0     0       0           0           0
%e A309119    1     1       1           1           0
%e A309119    2     0       2           0           1
%e A309119    3     1      10           1           0
%e A309119    4     3      11           2           0
%e A309119    5     3      12           1           1
%e A309119    6     2      20           0           1
%e A309119    7     2      21           1           1
%e A309119    8     0      22           0           2
%e A309119    9     1     100           1           0
%e A309119   10     3     101           2           0
%t A309119 Accumulate[Table[Total[IntegerDigits[n,3]/.(2->-1)],{n,0,80}]] (* _Harvey P. Dale_, Jun 23 2020 *)
%o A309119 (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)) ", "))
%Y A309119 Cf. A024023, A062756, A081603.
%K A309119 nonn,look,base
%O A309119 0,5
%A A309119 _Rémy Sigrist_, Jul 13 2019