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.

A140268 a(n) = negative integer -n presented in balanced ternary system.

This page as a plain text file.
%I A140268 #12 Jul 09 2025 04:29:37
%S A140268 2,21,20,22,211,210,212,201,200,202,221,220,222,2111,2110,2112,2101,
%T A140268 2100,2102,2121,2120,2122,2011,2010,2012,2001,2000,2002,2021,2020,
%U A140268 2022,2211,2210,2212,2201,2200,2202,2221,2220,2222,21111,21110,21112
%N A140268 a(n) = negative integer -n presented in balanced ternary system.
%C A140268 Sequence A117968 in ternary. (See there for more references.)
%e A140268 For example a(2) = 21, as -2 = -1*3 + 1*1.
%e A140268 Similarly, a(19) = 2102, as -19 = -1*27 + 1*9 + 0*3 + -1*1.
%o A140268 (Python)
%o A140268 from sympy.ntheory.factor_ import digits
%o A140268 def a117968(n):
%o A140268     if n==1: return 2
%o A140268     if n%3==0: return 3*a117968(n/3)
%o A140268     elif n%3==1: return 3*a117968((n - 1)/3) + 2
%o A140268     else: return 3*a117968((n + 1)/3) + 1
%o A140268 def a(n): return int("".join(map(str, digits(a117968(n), 3)[1:]))) # _Indranil Ghosh_, Jun 06 2017
%Y A140268 a(n) = A007089(A117968(n)). Cf. A140267.
%K A140268 nonn,base
%O A140268 1,1
%A A140268 _Antti Karttunen_, May 19 2008, prompted by _Eric Angelini_'s posting on SeqFan mailing list on Sep 15 2005