login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A140265
Permutation of natural numbers: a(n) = A140263(n-1)+1.
4
1, 2, 3, 6, 8, 4, 7, 5, 9, 18, 23, 16, 22, 17, 24, 12, 20, 10, 19, 11, 21, 15, 26, 13, 25, 14, 27, 54, 68, 52, 67, 53, 69, 48, 65, 46, 64, 47, 66, 51, 71, 49, 70, 50, 72, 36, 59, 34, 58, 35, 60, 30, 56, 28, 55, 29, 57, 33, 62, 31, 61, 32, 63, 45, 77, 43, 76, 44, 78, 39, 74, 37
OFFSET
1,2
PROG
(Scheme:) (define (A140265 n) (+ 1 (A140263 (- n 1))))
(Python)
from sympy import ceiling
from sympy.ntheory.factor_ import digits
def a004488(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3)
def a117968(n):
if n==1: return 2
if n%3==0: return 3*a117968(n/3)
elif n%3==1: return 3*a117968((n - 1)/3) + 2
else: return 3*a117968((n + 1)/3) + 1
def a117967(n): return 0 if n==0 else a117968(-n) if n<0 else a004488(a117968(n))
def a001057(n): return -(-1)**n*ceiling(n/2)
def a(n): return a117967(a001057(n - 1)) + 1 # Indranil Ghosh, Jun 07 2017
CROSSREFS
Inverse: A140266.
Sequence in context: A086254 A265297 A140266 * A349917 A191453 A191454
KEYWORD
nonn,look
AUTHOR
Antti Karttunen, May 19 2008
STATUS
approved