OFFSET
0,3
LINKS
PROG
(Python)
from sympy import ceiling
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 a117968(-n) if n<0 else a004488(a117968(n))
def a001057(n): return -(-1)**n*ceiling(n/2)
def a(n): return a117967(a001057(n)) # Indranil Ghosh, Jun 07 2017
CROSSREFS
AUTHOR
Antti Karttunen, May 19 2008, originally described in a posting at the SeqFan mailing list on Sep 15 2005.
STATUS
approved