OFFSET
1,2
MATHEMATICA
nn = 2^20; c = {1}; j = 1; u = 2; {1}~Join~Reap[Do[k = u; While[Nand[FreeQ[c, k], CoprimeQ[j, k], k != j + 1, k != j - 1], k++]; j = k; AppendTo[c, k]; If[k == i, Sow[k]]; If[k == u, While[MemberQ[c, u], u++]; c = DeleteCases[c, _?(# < u &)]], {i, 2, nn}]][[-1, -1]]
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Michael De Vlieger, May 05 2022
STATUS
approved