%I #11 Jan 12 2023 21:20:18
%S 1,2,4,3,9,5,10,6,25,35,7,15,12,55,11,20,8,45,21,40,16,65,13,30,14,27,
%T 33,17,34,18,85,95,51,24,119,49,68,22,153,39,136,28,187,99,170,26,75,
%U 57,50,32,105,63,80,38,115,23,60,36,125,145,19,76,29,87,31,62
%N Start with a(1)=1, a(2)=2. Thereafter, if gcd(a(n-2),a(n-1)) = 1 then a(n) is the smallest unused k such that gcd(a(n-2),k) > 1 and gcd(a(n-1),k) = 1, otherwise a(n) is the smallest unused k such that gcd(a(n-2),k) = 1 and gcd(a(n-1),k) > 1. If the latter is impossible, then a(n) = smallest missing number u. (See comments.)
%C A lexicographically earliest sequence. We write (i,j) to mean gcd(i,j) for brevity. Let rad(m) = A007947(m).
%C Define (i,j)=1 to be "closed" else "open". If we have i and j closed, then we find the least k not already in the sequence that is closed to i but open to j, otherwise we find same that is open to i but closed to j.
%C Condition [1], (i,j)=1 requires smallest unused k such that (i,k)=1 and (j,k)>1, given primes p|i, merely by finding the smallest missing k indivisible by any p.
%C Condition [2], (i,j)>1, requires smallest unused k such that (i,k)>1 and (j,k)=1 iff rad(i) does not divide rad(j).
%C Let S = {p | i} and T = {q | j}. If T contains S, then (j,k)=1 makes (i,k)>1 impossible.
%C Condition [3] allows a solution. In this case, we simply set a(n) = u, the smallest missing number in a(1..n-1).
%C The most conspicuous case of [3] is i = p^v and j = p^w, v < w. Since p^v | p^w, if a(n) = k is made such that (p^w,k)=1, then k is also coprime to p^v or any power of p. Hence we write a(n) = u.
%C Another, rare case of [3] is if i and j belong to R, the sequence of numbers that are products of the same squarefree kernel K. Suppose K = 6, then R = A003586. Now suppose i = 6*R(2) = 6*2 = 12 and j = 6*R(3) = 6*3 = 18. Indeed, if a(n) = k is made such that (18,k)=1, then k is also coprime to 12 and any number in 6*R. Hence in this case we write a(n) = u.
%H Michael De Vlieger, <a href="/A358534/a358534.png">Scatterplot of a(n)</a>, n = 1..2^16.
%H Michael De Vlieger, <a href="/A358534/a358534_1.png">Log log scatterplot of a(n)</a>, n = 1..2^14, showing records in red, local minima in blue, highlighting primes in green and other prime powers in gold.
%H Michael De Vlieger, <a href="/A358534/a358534_2.png">Log log scatterplot of a(n)</a>, n = 1..2^12, showing terms generated by condition [1] in blue, [2] in green, and [3] in red.
%t nn = 120; c[_] = False; q[_] = 1; f[n_] := Times @@ FactorInteger[n][[All, 1]]; Array[Set[{a[#], c[#]}, {#, True}] &, 2]; Set[{i, j, u}, {a[1], a[2], 3}]; Set[{r, s}, {f[i], f[j]}]; Do[Which[CoprimeQ[i, j], If[PrimeNu[j] == 1, While[c[q[s] s], q[s]++]; k = q[s]; While[Nand[! c[s k], CoprimeQ[i, k]], k++]; k *= s, k = u; While[Nand[! c[k], CoprimeQ[i, k], ! CoprimeQ[j, k]], k++]], Divisible[s, r], k = u, True, If[PrimeNu[i] == 1, While[c[q[r] s], q[r]++]; k = q[r]; While[Nand[! c[r k], CoprimeQ[j, k]], k++]; k *= r, k = u; While[Nand[! c[k], ! CoprimeQ[i, k], CoprimeQ[j, k]], k++]] ]; Set[{a[n], c[k], i, j, r, s}, {k, True, j, k, s, f[k]}]; If[k == u, While[c[u], u++]], {n, 3, nn}]; Array[a, nn]
%K nonn
%O 1,2
%A _Michael De Vlieger_ and _David James Sycamore_, Nov 20 2022