login
A246208
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).
6
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, 18, 78, 157, 315, 37, 75, 151, 631, 17, 77, 13, 27, 55, 155, 311, 623, 111, 1263, 35, 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
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.
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.
FORMULA
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).
As a composition of related permutations:
a(n) = A054429(A246210(n)).
a(n) = A246210(A246211(n)).
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
Inverse: A246207.
Related permutations: A140264, A054429, A246210, A246211.
Sequence in context: A332009 A175310 A175311 * A286091 A363554 A127011
KEYWORD
nonn
AUTHOR
Antti Karttunen, Aug 19 2014
STATUS
approved