%I #13 Sep 03 2024 01:06:14
%S 2,4,3,6,2,4,3,6,2,3,6,2,4,8,10,3,6,5,10,2,4,3,6,2,3,6,2,4,8,10,3,6,5,
%T 10,2,3,6,2,4,8,10,3,6,5,10,2,4,3,6,2,4,8,10,5,15,2,4,6,3,9,12,8,10,5,
%U 15,2,4,6,5,10,2,4,6,3,2,4,6,3,9,2,4,6,3,9,12,8,10,5,15,2,4,3,6,2,4
%N Lexicographically earliest sequence where a(n) is the length of the n-th block of distinct integers sharing a prime factor.
%C Does every positive integer > 1 appear eventually?
%H Michael S. Branicky, <a href="/A375907/b375907.txt">Table of n, a(n) for n = 1..10000</a>
%e The sequence and blocks begin
%e n = 1 2 3 4 5 6 7 8 9 ...
%e a(n) = 2,4, 3,6,2,4, 3,6,2, 3,6,2,4,8,10, 3,6, ...
%e block \-/ \-----/ \---/ \----------/ \-/
%e length 2 4 3 6 2 ...
%e a(7) = 3 is the start of a new block since it has no common factor with the preceding a(6) = 4.
%e The block lengths are the sequence itself.
%o (Python)
%o from math import gcd
%o from itertools import count, islice
%o def agen(): # generator of terms
%o n, an, alst = 1, 2, [-3]
%o while True:
%o b = [next(i for i in count(2) if gcd(i, alst[-1])==1)]
%o for i in range(an-1):
%o b += [next(j for j in count(2) if j not in b and gcd(j, b[-1])!=1)]
%o yield from b
%o alst.extend(b)
%o n, an = n+1, alst[n+1]
%o print(list(islice(agen(), 95))) # _Michael S. Branicky_, Sep 02 2024
%K nonn
%O 1,1
%A _Bryle Morga_, Sep 02 2024