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.

A257869 Nonnegative integers with an equal number of occurrences of all trits in balanced ternary representation.

This page as a plain text file.
%I A257869 #19 May 06 2021 11:04:31
%S A257869 6,8,136,138,144,154,156,160,164,168,170,180,186,188,208,210,214,218,
%T A257869 222,224,232,236,248,258,260,266,288,294,296,312,314,320,3406,3412,
%U A257869 3414,3430,3432,3438,3484,3486,3492,3510,3568,3574,3576,3592,3594,3600,3622
%N A257869 Nonnegative integers with an equal number of occurrences of all trits in balanced ternary representation.
%H A257869 Alois P. Heinz, <a href="/A257869/b257869.txt">Table of n, a(n) for n = 1..10000</a>
%H A257869 Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>
%e A257869 6 = 1L0_bal3, 8 = 10L_bal3, 136 = 1LL001_bal3, 138 = 1LL010_bal3, 144 = 1LL100_bal3, where L represents (-1).
%p A257869 p:= proc(n) local d, m, r; m:=n; r:=0;
%p A257869       while m>0 do
%p A257869         d:= irem(m, 3, 'm');
%p A257869         if d=2 then m:=m+1 fi;
%p A257869         r:= r+x^d
%p A257869       od;
%p A257869       simplify(r/(1+x+x^2))::integer
%p A257869     end:
%p A257869 a:= proc(n) option remember; local k;
%p A257869       for k from 1+`if`(n=1, 0, a(n-1)) by 1
%p A257869       while not p(k) do od; k
%p A257869     end:
%p A257869 seq(a(n), n=1..70);
%o A257869 (Python)
%o A257869 def a(n):
%o A257869     s=[]
%o A257869     x=0
%o A257869     while n>0:
%o A257869         x=n%3
%o A257869         n//=3
%o A257869         if x==2:
%o A257869             x=-1
%o A257869             n+=1
%o A257869         s.append(x)
%o A257869     return s
%o A257869 print([n for n in range(1, 5001) if a(n).count(1)==a(n).count(-1) and a(n).count(-1)==a(n).count(0)]) # _Indranil Ghosh_, Jun 07 2017
%Y A257869 Cf. A117967, A140267, A257867, A257868, A258410.
%Y A257869 Subsequence of A174658.
%K A257869 nonn,base
%O A257869 1,1
%A A257869 _Alois P. Heinz_, May 11 2015