OFFSET
1,2
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..178 (terms 1..140 from Michael De Vlieger)
MATHEMATICA
Block[{c, j, k, m, p, r, nn},
nn = 6000; c[_] := False; m[_] := 1; j = 2; c[1] = c[2] = True; r = 0;
{1, 2}~Join~Monitor[Reap[Do[
If[PrimePowerQ[j],
Set[{p, k, m}, {#1, #1^(#2 - 1), #1^(#2 - 1)}] & @@
FactorInteger[j][[1]]; While[And[c[k*p], k != 0], k--];
If[k == 0, k = m; While[c[k*p], k++]]; k *= p,
k = j - 1; While[And[Or[c[k], CoprimeQ[j, k]], k != 1], k--];
If[k == 1, k += j; While[Or[c[k], CoprimeQ[j, k] ], k++] ] ];
If[k > r, r = k; Sow[n]];
Set[{c[k], j}, {True, k}], {n, 3, nn}] ][[-1, 1]], n] ]
PROG
(Python)
from math import gcd
from itertools import count, islice
def A387074_gen(): # generator of terms
m, mset, c, a = 2, {2}, 3, 2
yield from (1, 2)
for j in count(3):
for i in range(m-1, c-1, -1):
if i not in mset and gcd(i, m)>1:
if i>a:
yield j
a = i
break
else:
for i in count(max(c, m+1)):
if i not in mset and gcd(i, m)>1:
if i>a:
yield j
a = i
break
m = i
mset.add(i)
while c in mset:
mset.remove(c)
c += 1
CROSSREFS
KEYWORD
nonn
AUTHOR
Michael De Vlieger, Aug 15 2025
STATUS
approved
