login
A254115
Permutation of natural numbers: a(n) = A254104(A048673(n)).
4
1, 2, 3, 4, 5, 6, 7, 8, 13, 10, 11, 12, 9, 14, 21, 16, 15, 26, 23, 20, 43, 22, 19, 24, 63, 18, 33, 28, 31, 42, 47, 32, 55, 30, 127, 52, 27, 46, 87, 40, 17, 86, 39, 44, 107, 38, 29, 48, 75, 126, 91, 36, 95, 66, 191, 56, 53, 62, 45, 84, 35, 94, 1023, 64, 255, 110, 25, 60, 183, 254, 79, 104, 37, 54, 171, 92, 125, 174, 59, 80, 4095, 34, 61, 172, 77, 78
OFFSET
1,2
FORMULA
a(n) = A254104(A048673(n)).
Other identities. For all n >= 1:
a(n) = a(2n)/2. [Even bisection halved gives back the sequence itself.]
A254117(n) = (a((2*n)+1) - 1)/2. [Likewise, the odd bisection induces A254117.]
PROG
(Scheme, different implementations)
(define (A254115 n) (A254104 (A048673 n)))
(definec (A254115 n) (cond ((<= n 1) n) ((even? n) (* 2 (A254115 (/ n 2)))) (else (+ 1 (* 2 (A254104 (Ainv_of_A007310off0 (A003961 n))))))))
(define (Ainv_of_A007310off0 n) (+ (* 2 (floor->exact (/ n 6))) (/ (- (modulo n 6) 1) 4)))
(Python)
from sympy import factorint, nextprime
from operator import mul
def a048673(n):
f = factorint(n)
return 1 if n==1 else (1 + reduce(mul, [nextprime(i)**f[i] for i in f]))/2
def a254104(n):
if n==0: return 0
if n%3==0: return 1 + 2*a254104(2*n/3 - 1)
elif n%3==1: return 1 + 2*a254104(2*(n - 1)/3)
else: return 2*a254104((n - 2)/3 + 1)
def a(n): return a254104(a048673(n)) # Indranil Ghosh, Jun 06 2017
CROSSREFS
Inverse: A254116.
Fixed points: A254099.
Related permutations: A048673, A254104, A254117.
Sequence in context: A180628 A165306 A254116 * A032986 A032977 A133245
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 04 2015
STATUS
approved