%I #18 Jun 07 2017 10:45:50
%S 0,1,5,22,71,2,35,15,99,225,531,66,213,516,1899,7,73,172,307,127,1369,
%T 36,3,52,304,148,1246,5408,17461,620,1567,5321,41591,194,698,6,21,69,
%U 1489,5165,16975,174,142234,643,17287,587,695,173,5195,72,605,4770,23,1761,12051,4175,24134,389,137,431,3758,945,11964,392,419,482,11,2872,104,37,3830,4,49,16
%N Self-inverse permutation of natural numbers: a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 0, a(n) = A117967(1+a(-(A117966(n)))), otherwise a(n) = A117968(a(A117966(n)-1)).
%C This is an instance of entanglement permutation, where complementary pair A117967/A117968 (positive and negative part of inverse of balanced ternary enumeration of integers, respectively) is entangled with the same pair in the opposite order: A117967/A117968, with a(0) set to 0 and a(1) set to 1.
%H Antti Karttunen, <a href="/A246211/b246211.txt">Table of n, a(n) for n = 0..2187</a>
%H Indranil Ghosh, <a href="/A246211/a246211.txt">Python program to generate the sequence</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 0, a(n) = A117967(1+a(-(A117966(n)))), otherwise a(n) = A117968(a(A117966(n)-1)).
%o (Scheme, with memoizing definec-macro from _Antti Karttunen_'s IntSeq-library)
%o (definec (A246211 n) (cond ((<= n 1) n) ((negative? (A117966 n)) (A117967 (+ 1 (A246211 (- (A117966 n)))))) (else (A117968 (A246211 (- (A117966 n) 1))))))
%Y Related or similar permutations: A246207, A246208, A246209, A246210, A004488, A245812, A054429.
%Y Cf. A117966, A117967, A117968.
%K nonn
%O 0,3
%A _Antti Karttunen_, Aug 19 2014