OFFSET
1,2
LINKS
FORMULA
a(n) = Z->N(A117966(n-1)), where Z->N(z) = 2z if z>0 else 2|z|+1.
PROG
(define (Z->N n) (if (positive? n) (* n 2) (+ 1 (* 2 (- n))))))
(Python)
def a117966(n):
if n==0: return 0
if n%3==0: return 3*a117966(n/3)
elif n%3==1: return 3*a117966((n - 1)/3) + 1
else: return 3*a117966((n - 2)/3) - 1
def Z(z): return 2*z if z>0 else 2*abs(z) + 1
def a(n): return Z(a117966(n - 1)) # Indranil Ghosh, Jun 07 2017
CROSSREFS
AUTHOR
Antti Karttunen, May 19 2008
STATUS
approved