%I #10 Jun 06 2017 10:33:24
%S 1,2,3,6,5,4,10,7,11,21,9,31,16,15,23,27,63,13,43,8,19,53,14,37,45,47,
%T 95,26,22,17,511,127,12,91,39,18,85,62,29,2047,30,38,111,20,54,75,42,
%U 55,157,35,46,174,25,79,24,59,77,303,123,94,78,167,87,223,61,103,699,191,41,107,183,125,431,28,71,84,60,93,110,767,51
%N Permutation of natural numbers: a(n) = A254104(A249746(1+n)-1).
%H Antti Karttunen, <a href="/A254117/b254117.txt">Table of n, a(n) for n = 1..8192</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(n) = A254104(A249746(1+n)-1).
%F a(n) = (A254115((2*n)+1)-1) / 2. [Obtained also from the odd bisection of A254115.]
%o (Scheme, two versions)
%o (define (A254117 n) (A254104 (+ -1 (A249746 (+ 1 n)))))
%o (define (A254117 n) (/ (+ -1 (A254115 (+ 1 n n))) 2))
%o (Python)
%o from sympy import factorint, nextprime
%o from operator import mul
%o def a048673(n):
%o f = factorint(n)
%o return 1 if n==1 else (1 + reduce(mul, [nextprime(i)**f[i] for i in f]))/2
%o def a254104(n):
%o if n==0: return 0
%o if n%3==0: return 1 + 2*a254104(2*n/3 - 1)
%o elif n%3==1: return 1 + 2*a254104(2*(n - 1)/3)
%o else: return 2*a254104((n - 2)/3 + 1)
%o def a254115(n): return a254104(a048673(n))
%o def a(n): return (a254115(2*n + 1) - 1)/2 # _Indranil Ghosh_, Jun 06 2017
%Y Inverse: A254118.
%Y Other related permutations: A249746, A254104, A254115.
%K nonn
%O 1,2
%A _Antti Karttunen_, Feb 05 2015
|