OFFSET
0,3
COMMENTS
This is an instance of entanglement permutation, where complementary pair A117968/A117967 (negative and positive part of inverse of balanced ternary enumeration of integers, respectively) is entangled with complementary pair A005843/A005408 (even and odd numbers respectively), with a(0) set to 0 and a(1) set to 1.
LINKS
FORMULA
PROG
(Scheme, with memoizing definec-macro from Antti Karttunen's IntSeq-library)
(definec (A246208 n) (cond ((<= n 1) n) ((negative? (A117966 n)) (* 2 (A246208 (- (A117966 n))))) (else (+ 1 (* 2 (A246208 (- (A117966 n) 1)))))))
(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 a(n):
if n<2: return n
x=a117966(n)
if x<1: return 2*a(-x)
else: return 1 + 2*a(x - 1)
print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Aug 19 2014
STATUS
approved