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.

A355639 a(n) is the least k > 0 such that the balanced ternary expansion of k*n contains as many negative trits as positive trits.

This page as a plain text file.
%I A355639 #7 Jul 13 2022 14:43:22
%S A355639 1,2,1,2,2,4,1,8,1,2,2,14,2,2,4,4,1,8,1,14,1,8,7,2,1,16,1,2,2,8,2,2,1,
%T A355639 14,4,2,2,2,7,2,2,4,4,2,10,4,1,4,1,2,8,8,1,8,1,8,1,14,4,4,1,8,1,8,5,2,
%U A355639 7,14,2,2,1,2,1,2,1,16,7,2,1,8,1,2,2,8
%N A355639 a(n) is the least k > 0 such that the balanced ternary expansion of k*n contains as many negative trits as positive trits.
%C A355639 The sequence is well defined: for n > 0, by the pigeonhole principle, there are necessarily two distinct integers i and j (say with i > j) such that 3^i == 3^j (mod n); the value 3^i - 3^j is a positive multiple of n containing exactly one positive trit and one negative trit, so a(n) <= (3^i - 3^j) / n.
%F A355639 a(n) = 1 iff n belongs to A174658.
%e A355639 For n = 5:
%e A355639 - the first multiple of 5 (alongside their balanced ternary expansions) are:
%e A355639       k  k*5  bter(k*5)  #1  #T
%e A355639       -  ---  ---------  --  --
%e A355639       1    5        1TT   1   2
%e A355639       2   10        101   2   0
%e A355639       3   15       1TT0   1   2
%e A355639       4   20       1T1T   2   2
%e A355639 - negative and positive trits are first balanced for k = 4,
%e A355639 - so a(5) = 4.
%o A355639 (PARI) a(n) = { for (k=1, oo, my (m=k*n, s=0, d); while (m, m=(m-d=[0,1,-1][1+m%3])/3; s+=d); if (s==0, return (k))) }
%Y A355639 See A351599 for a similar sequence.
%Y A355639 Cf. A065363, A174658, A355640.
%K A355639 nonn,base
%O A355639 0,2
%A A355639 _Rémy Sigrist_, Jul 11 2022