OFFSET
1,1
COMMENTS
Sequence A117968 in ternary. (See there for more references.)
EXAMPLE
For example a(2) = 21, as -2 = -1*3 + 1*1.
Similarly, a(19) = 2102, as -19 = -1*27 + 1*9 + 0*3 + -1*1.
PROG
(Python)
from sympy.ntheory.factor_ import digits
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 a(n): return int("".join(map(str, digits(a117968(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.
STATUS
approved