%I #42 Mar 14 2022 23:40:13
%S 1,2,4,6,3,9,12,8,10,5,15,18,14,7,21,24,16,20,25,30,22,11,33,27,36,26,
%T 13,39,42,28,32,34,17,51,45,35,49,56,38,19,57,48,40,55,77,63,54,44,
%U 121,66,46,23,69,60,50,52,91,105,72,58,29,87,75,65,104,62,31,93,78,64,68,85,95,76,74,37,111,81,84,70,115,207,96,80
%N a(1)=1, a(2)=2; thereafter, a(n) is the smallest number m not yet in the sequence such that gcd(m,a(n-1)) > 1 and gcd(m,a(n-2))=1, except that the second condition is ignored if it would imply that no choice for m were possible.
%C This is an intermediate sequence between the EKG sequence A064413 (which only involves the first condition) and the Enots Wolley sequence A336957 (which involves both conditions).
%C By ignoring the second condition when necessary we guarantee that a(n) always exists (because it always exists for the EKG sequence), and so no backtracking is needed in this sequence.
%C The second condition is ignored precisely when every prime that divides a(n-1) also divides a(n-2).
%C Conjecture 1: Every positive number appears.
%C Conjecture 2: The primes are the slowest numbers to appear. That is, when a prime p appears here, all numbers less than p have already appeared. To put this another way, the record high points in A352188 ("when does n appear") are exactly the primes (and 1).
%C Conjecture 3: When a prime p first divides some term, that term is 2*p, which is followed by p then 3p. [It seems possible that we could see 2*a, 6*b, 3*p, p, 2*p. This does not happen in the first 10000 terms, but I can't prove it never happens. I can prove that every prime divides some term, and that the primes appear in increasing order. Conjecture 3 might be refuted by a more extensive calculation.]
%H N. J. A. Sloane, <a href="/A352187/b352187.txt">Table of n, a(n) for n = 1..20000</a>
%p # To produce the first 1000 terms:
%p with(numtheory):
%p omega := proc(n) nops(numtheory[factorset](n)) end proc:
%p hit:=Array(1..100000,0);
%p M:=100000;
%p a:=[1,2]; K:=1; L:=2; hit[1]:=1; hit[2]:=2;
%p for n from 3 to 1000 do
%p sw1:=0;
%p # find a[n]
%p if factorset(L) subset factorset(K) then
%p # use EKG rule
%p for i from 1 to M do
%p if hit[i]=0 and igcd(i,L)>1 then a:=[op(a),i]; K:=L; L:=i; hit[i]:=n; sw1:=1; break; fi;
%p od:
%p if sw1=0 then error("failed EKG, n, i =", n,i); fi;
%p else
%p # use Enots Wolley rule
%p for i from 1 to M do
%p if hit[i]=0 and igcd(i,L)>1 and igcd(i,K)=1 then a:=[op(a),i]; K:=L; L:=i; hit[i]:=n; sw1:=1; break; fi;
%p od:
%p if sw1=0 then error("failed WOLLEY, n, i =", n,i); fi;
%p fi:
%p od:
%p a;
%o (Python)
%o from math import gcd
%o from itertools import count, islice
%o from sympy import primefactors
%o def A352187_gen(): # generator of terms
%o bset, blist, mmax = {1,2}, [1,2], 3
%o yield from blist
%o while True:
%o for m in count(mmax):
%o if gcd(m,blist[-1]) > 1 and m not in bset:
%o if all(blist[-2] % p == 0 for p in primefactors(blist[-1])) or gcd(m,blist[-2]) == 1:
%o yield m
%o blist = [blist[-1],m]
%o bset.add(m)
%o while mmax in bset:
%o mmax += 1
%o break
%o A352187_list = list(islice(A352187_gen(),20)) # _Chai Wah Wu_, Mar 14 2022
%Y Cf. A064413, A336957, A352188 (when n appears), A352189, A352190.
%Y Records: A352191, A352192.
%K nonn
%O 1,2
%A _N. J. A. Sloane_, Mar 12 2022