%I #27 Apr 28 2021 10:10:50
%S 0,1,2,5,11,3,10,4,22,45,91,9,19,39,183,7,21,23,90,44,182,20,6,8,38,
%T 18,78,157,315,37,75,151,631,17,77,13,27,55,155,311,623,111,1263,35,
%U 303,47,181,43,365,41,89,367,15,79,314,156,630,76,16,36,150,74,302,180,46,88,14,366,42,40,364,12,54,26,110,34
%N Permutation of nonnegative integers: a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 2*a(-(A117966(n))), otherwise a(n) = 1 + 2*a(A117966(n)-1).
%C 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.
%C Thus this shares with A140264 the property that apart from a(0) = 0, even numbers occur only in positions given by A117968, and odd numbers only in positions given by A117967.
%H Antti Karttunen, <a href="/A246208/b246208.txt">Table of n, a(n) for n = 0..6561</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) < 1, a(n) = 2*a(-(A117966(n))), otherwise a(n) = 1 + 2*a(A117966(n)-1).
%F As a composition of related permutations:
%F a(n) = A054429(A246210(n)).
%F a(n) = A246210(A246211(n)).
%o (Scheme, with memoizing definec-macro from _Antti Karttunen_'s IntSeq-library)
%o (definec (A246208 n) (cond ((<= n 1) n) ((negative? (A117966 n)) (* 2 (A246208 (- (A117966 n))))) (else (+ 1 (* 2 (A246208 (- (A117966 n) 1)))))))
%o (Python)
%o def a117966(n):
%o if n==0: return 0
%o if n%3==0: return 3*a117966(n//3)
%o elif n%3==1: return 3*a117966((n - 1)//3) + 1
%o else: return 3*a117966((n - 2)//3) - 1
%o def a(n):
%o if n<2: return n
%o x=a117966(n)
%o if x<1: return 2*a(-x)
%o else: return 1 + 2*a(x - 1)
%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 07 2017
%Y Inverse: A246207.
%Y Related permutations: A140264, A054429, A246210, A246211.
%Y Cf. A005408, A005843, A117966, A117967, A117968.
%K nonn
%O 0,3
%A _Antti Karttunen_, Aug 19 2014
|