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”).

A140266
Inverse permutation to A140265.
3
1, 2, 3, 6, 8, 4, 7, 5, 9, 18, 20, 16, 24, 26, 22, 12, 14, 10, 19, 17, 21, 13, 11, 15, 25, 23, 27, 54, 56, 52, 60, 62, 58, 48, 50, 46, 72, 74, 70, 78, 80, 76, 66, 68, 64, 36, 38, 34, 42, 44, 40, 30, 32, 28, 55, 53, 57, 49, 47, 51, 61, 59, 63, 37, 35, 39, 31, 29, 33, 43, 41, 45
OFFSET
1,2
FORMULA
a(n) = Z->N(A117966(n-1)), where Z->N(z) = 2z if z>0 else 2|z|+1.
PROG
(Scheme:) (string-append (define (A140266 n) (Z->N (A117966 (- n 1))))
(define (Z->N n) (if (positive? n) (* n 2) (+ 1 (* 2 (- n))))))
(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 Z(z): return 2*z if z>0 else 2*abs(z) + 1
def a(n): return Z(a117966(n - 1)) # Indranil Ghosh, Jun 07 2017
CROSSREFS
Inverse: A140265. a(n) = A140264(n-1)+1.
Sequence in context: A133441 A086254 A265297 * A140265 A349917 A191453
KEYWORD
nonn,look,hear
AUTHOR
Antti Karttunen, May 19 2008
STATUS
approved