%I #17 Jan 04 2023 15:51:55
%S 1,2,3,4,6,10,8,5,14,15,7,9,21,12,18,22,16,11,26,33,13,24,39,27,30,42,
%T 25,20,35,34,28,17,38,51,19,36,57,46,45,23,40,69,54,48,32,50,58,44,29,
%U 55,87,60,63,62,49,31,56,93,66,72,52,70,65,64,75,74,78,37,68,111,82,81
%N a(1)=1, a(2)=2, a(3)=3; for n >= 4, a(n) is the smallest positive integer not occurring earlier in the sequence such that gcd(a(n-2), a(n)) is a prime.
%C Sequence is probably a permutation of the positive integers.
%H Robert Israel, <a href="/A122397/b122397.txt">Table of n, a(n) for n = 1..10000</a>
%p A[1]:= 1: A[2]:= 2: A[3]:= 3:
%p S:= {$4..500}:
%p for n from 4 do
%p P:= numtheory:-factorset(A[n-2]);
%p for s in S do
%p if member(igcd(s,A[n-2]),P) then
%p A[n]:= s; S:= S minus {s}; break
%p fi
%p od;
%p if not assigned(A[n]) then break fi
%p od:
%p seq(A[i],i=1..n-1); # _Robert Israel_, Jan 04 2023
%t f[s_] := Block[{k = 1}, While[MemberQ[s, k] || ! PrimeQ[GCD[s[[ -2]], k]], k++ ]; Append[s, k] ]; Nest[f, {1, 2, 3}, 70] (* _Ray Chandler_, Sep 05 2006 *)
%Y Cf. A122398.
%K nonn,look
%O 1,2
%A _Leroy Quet_, Aug 31 2006
%E Corrected and extended by _Ray Chandler_, Sep 05 2006
|