[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A246210
Permutation of nonnegative integers: a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 1 + 2*a(-(A117966(n))), otherwise a(n) = 2*a(A117966(n)-1).
5
0, 1, 3, 6, 12, 2, 13, 7, 25, 50, 100, 14, 28, 56, 200, 4, 26, 24, 101, 51, 201, 27, 5, 15, 57, 29, 113, 226, 452, 58, 116, 232, 904, 30, 114, 10, 20, 40, 228, 456, 912, 80, 1808, 60, 464, 48, 202, 52, 402, 54, 102, 400, 8, 112, 453, 227, 905, 115, 31, 59, 233, 117, 465, 203, 49, 103, 9, 401, 53, 55, 403, 11, 41, 21, 81, 61
OFFSET
0,3
COMMENTS
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 complementary pair A005843/A005408 (even and odd numbers respectively), with a(0) set to 0 and a(1) set to 1.
This implies that apart from a(1) = 1, even numbers occur only in positions given by A117967, and odd numbers only in positions given by A117968.
FORMULA
a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 1 + 2*a(-(A117966(n))), otherwise a(n) = 2*a(A117966(n)-1).
As a composition of related permutations:
a(n) = A054429(A246208(n)).
a(n) = A246208(A246211(n)).
PROG
(Scheme, with memoizing definec-macro from Antti Karttunen's IntSeq-library)
(definec (A246210 n) (cond ((<= n 1) n) ((negative? (A117966 n)) (+ 1 (* 2 (A246210 (- (A117966 n)))))) (else (* 2 (A246210 (- (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 1 + 2*a(-x)
else: return 2*a(x - 1)
print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017
CROSSREFS
Inverse: A246209.
Similar or related permutations: A054429, A246208, A246211.
Sequence in context: A356221 A102253 A359799 * A302784 A329889 A296347
KEYWORD
nonn
AUTHOR
Antti Karttunen, Aug 19 2014
STATUS
approved