OFFSET
0,3
COMMENTS
This is an instance of entanglement permutation, where complementary pair A005843/A005408 (even and odd numbers respectively) is entangled with complementary pair A117968/A117967 (negative and positive part of inverse of balanced ternary enumeration of integers, respectively), with a(0) set to 0 and a(1) set to 1.
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..8191
Antti Karttunen, Pin & logarithmic scatter plots computed for range 0..2047 only (computed with OEIS "graph" command)
FORMULA
PROG
(Scheme, with memoizing definec-macro from Antti Karttunen's IntSeq-library)
(definec (A246207 n) (cond ((<= n 1) n) ((even? n) (A117968 (A246207 (/ n 2)))) (else (A117967 (+ 1 (A246207 (/ (- n 1) 2)))))))
(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 a117968(-n) if n<0 else a004488(a117968(n))
def a(n): return n if n<2 else a117968(a(n/2)) if n%2==0 else a117967(1 + a((n - 1)/2)) # Indranil Ghosh, Jun 07 2017
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Antti Karttunen, Aug 19 2014
STATUS
approved