%I #13 May 22 2022 14:05:46
%S 1,3,2,6,7,4,5,12,15,14,13,8,11,10,9,24,19,27,17,28,33,26,29,16,35,22,
%T 18,20,23,42,37,48,21,38,25,54,31,34,51,56,43,30,41,52,63,58,53,32,77,
%U 70,39,44,47,36,65,40,69,46,61,84,59,74,45,96,55,78,71
%N Lexicographically earliest sequence of distinct positive integers such that a(1) = 1 and for any n > 1, n / gcd(n, a(n)) and a(n) / gcd(n, a(n)) are prime.
%C This sequence is a self-inverse permutation of the positive integers that preserves the number of prime divisors (with or without multiplicity).
%H Michael De Vlieger, <a href="/A354225/b354225.txt">Table of n, a(n) for n = 1..10000</a>
%H Michael De Vlieger, <a href="/A354225/a354225.png">Annotated log-log plot of a(n)</a>, n = 1..2^14, showing records in red, local minima in blue, highlighting primes in green, fixed points in gold, and composite prime powers in magenta.
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(prime(2*n)) = prime(2*n-1) (where prime(n) denotes the n-th prime number).
%e The first terms are:
%e n a(n) g=gcd(n, a(n)) n/g a(n)/g
%e -- ---- -------------- --- ------
%e 1 1 1 1 1
%e 2 3 1 2 3
%e 3 2 1 3 2
%e 4 6 2 2 3
%e 5 7 1 5 7
%e 6 4 2 3 2
%e 7 5 1 7 5
%e 8 12 4 2 3
%e 9 15 3 3 5
%e 10 14 2 5 7
%e 11 13 1 11 13
%e 12 8 4 3 2
%e 13 11 1 13 11
%e 14 10 2 7 5
%t nn = 120; c[_] = 0; a[1] = c[1] = 1; u = 2; Do[k = u; While[Nand[c[k] == 0, AllTrue[{i/#, k/#}, PrimeQ] &@ GCD[i, k]], k++]; Set[{a[i], c[k]}, {k, i}]; If[k == u, While[c[u] > 0, u++]], {i, 2, nn}]; Array[a, nn] (* _Michael De Vlieger_, May 22 2022 *)
%o (PARI) s=0; for (n=1, 67, for (v=1, oo, if (!bittest(s, v) && (n==1 || (isprime(n/g=gcd(n,v)) && isprime(v/g))), print1 (v", "); s+=2^v; break)))
%Y Cf. A122280.
%K nonn
%O 1,2
%A _Rémy Sigrist_, May 20 2022