%I #16 Sep 10 2024 18:42:35
%S 3,2,5,7,4,9,11,13,17,19,8,23,15,29,31,37,41,43,47,49,53,59,16,61,67,
%T 71,25,27,73,79,83,89,97,101,103,107,109,113,121,127,91,131,137,139,
%U 149,151,32,157,163,167,173,179,181,191,85,193,57,197,199,211,223,227,229,233,239,241,251,257,263
%N Same definition as A247665, except first term is 3.
%o (SageMath) # from _Nadia Heninger_, Oct 28 2014: s is the starting point (2 in A247665, 3 here).
%o def gen(s):
%o sequence = [s]
%o available = range(2, 2*s)
%o available.pop(available.index(s))
%o yield s
%o while True:
%o available.extend(range(available[-1]+1, next_prime(available[-1])+1))
%o for i, e in enumerate(available):
%o if all([gcd(e, sequence[j])==1 for j in range(-len(sequence)/2, 0)]):
%o available.pop(i)
%o sequence.append(e)
%o yield(e)
%o break
%o g = gen(3)
%o [g.next() for i in range(40)] # gets first 40 terms
%o (Python)
%o from itertools import count, islice
%o from math import gcd
%o from collections import deque
%o def A249559_gen(): # generator of terms
%o aset, aqueue, c, f = {3}, deque([3]), 2, True
%o yield 3
%o while True:
%o for m in count(c):
%o if m not in aset and all(gcd(m,a) == 1 for a in aqueue):
%o yield m
%o aset.add(m)
%o aqueue.append(m)
%o if f: aqueue.popleft()
%o f = not f
%o while c in aset:
%o c += 1
%o break
%o A249559_list = list(islice(A249559_gen(),50)) # _Chai Wah Wu_, May 19 2022
%Y Cf. A247665.
%K nonn
%O 1,1
%A _N. J. A. Sloane_, Nov 02 2014