OFFSET
0,3
COMMENTS
Sequence A117967 in ternary. (See there for more references.)
From Daniel Forgues, Mar 22 2010: (Start)
The balanced ternary digits {-1, 0, +1} (balanced trits) of a(n) are being represented by {2, 0, 1} respectively in this sequence.
The sign of a(n) is given by the sign of its leading trit.
The number k, k >= 0, of trailing "0"s of a(n) indicates that a(n) is divisible by 3^k.
a(n) is even/odd if it has an even/odd count of nonzero trits. (End)
LINKS
Daniel Forgues, Table of n, a(n) for n = 0..100000
Jeff Connelly, Ternary Computing Testbed 3-Trit Computer Architecture, 2008. - Daniel Forgues, Mar 23 2010
Brian Hayes, Third Base, American Scientist, November-December 2001. - Daniel Forgues, Mar 23 2010
Ternary.info Forum, Balanced ternary arithmetics. - Daniel Forgues, Mar 23 2010
EXAMPLE
For example a(2) = 12, as 1*3 + -1*1 = 2. Similarly, a(19) = 1201, as 1*27 + -1*9 + 0*3 + 1*1 = 19.
PROG
(Python)
from sympy.ntheory.factor_ import digits
def a004488(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3)
def a117968(n):
if n==1: return 2
if n%3==0: return 3*a117968(n/3)
elif n%3==1: return 3*a117968((n - 1)/3) + 2
else: return 3*a117968((n + 1)/3) + 1
def a117967(n): return 0 if n==0 else a004488(a117968(n))
def a(n): return int("".join(map(str, digits(a117967(n), 3)[1:]))) # Indranil Ghosh, Jun 06 2017
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, May 19 2008, prompted by Eric Angelini's posting on SeqFan mailing list on Sep 15 2005.
EXTENSIONS
Definition edited by Daniel Forgues, Mar 24 2010
STATUS
approved