%I #21 Jan 16 2023 09:10:46
%S 2,9,4,15,8,21,10,27,14,25,6,35,12,49,16,33,20,39,22,45,26,51,28,55,
%T 18,65,24,77,30,91,32,57,34,63,38,69,40,81,44,75,46,85,36,95,42,115,
%U 48,119,50,87,52,93,56,99,58,105,62,111,64,117,68,121,54,125,66,133,60,143,70,123,74,129
%N a(1) = 2; for n > 1, a(n) = smallest composite number not occurring earlier which does not share a factor with a(n-1).
%C The sequence excludes primes as otherwise the terms would simply be all the ordered integers >= 2. The terms appear to cluster around two lines; the lower line is a(n) ~ n while the upper lines starts with a gradient of approximately 2 and then slowly flattens. It is possible this gradient approaches 1 as n->infinity.
%H Scott R. Shannon, <a href="/A339316/b339316.txt">Table of n, a(n) for n = 1..10000</a>
%e a(2) = 9, as a(1) = 2 thus a(2) cannot contain 2 as a factor and cannot be a prime. The lowest unused composite matching these criteria is 9.
%e a(3) = 4, as a(2) = 9 and thus a(3) cannot contain 3 as a factor and cannot be a prime. The lowest unused composite matching these criteria is 4.
%e a(4) = 15, as a(3) = 4 and thus a(4) cannot contain 2 as a factor and cannot be a prime. The lowest unused composite matching these criteria is 15.
%o (PARI) isok(k, fprec, v) = {if (!isprime(k) && #select(x->(x==k), v) == 0, #setintersect(Set(factor(k)[,1]), fprec) == 0;);}
%o lista(nn) = {my(va= vector(nn)); va[1] = 2; for (n=2, nn, my(k=2, fprec = Set(factor(va[n-1])[,1])); while (! isok(k, fprec, va), k++); va[n] = k;); va;} \\ _Michel Marcus_, Nov 30 2020
%o (Python)
%o from sympy import isprime, primefactors as pf
%o def aupton(terms):
%o alst, aset = [2], {2}
%o for n in range(2, terms+1):
%o m, prevpf = 4, set(pf(alst[-1]))
%o while m in aset or isprime(m) or set(pf(m)) & prevpf != set(): m += 1
%o alst.append(m); aset.add(m)
%o return alst
%o print(aupton(72)) # _Michael S. Branicky_, Feb 09 2021
%Y Cf. A337687, A000961, A064413, A336957, A098550, A020639, A280864.
%K nonn
%O 1,1
%A _Scott R. Shannon_, Nov 30 2020