%I #27 Sep 05 2024 17:16:33
%S 2,3,6,7,14,15,22,23,26,30,31,34,35,42,43,58,59,62,66,67,70,71,78,79,
%T 86,87,94,95,106,107,114,115,122,123,130,131,134,138,139,142,143,158,
%U 159,166,167,170,174,175,178,179,186,187,194,195,210,211,214,215,222
%N Lexicographically earliest sequence of distinct integers greater than 1 such that a(n) mod a(i)^2 >= a(i) for all i < n.
%C In the sieve of Eratosthenes, first the even numbers are removed, then the multiples of 3, then multiples of 5. In this sieve first the numbers greater than 2 and modulo 0 or 1 (mod 4) are removed leaving (1) 2, 3, 6, 7, 10, 11, 14, 15. Then the numbers greater than 3 and modulo 0, 1, 2 (mod 9) are removed leaving (1) 2, 3, 6, 7, 14, 15. Then numbers modulo 0, 1, 2, 3, 4, 5 (mod 36) are removed.
%H Robert Israel, <a href="/A335099/b335099.txt">Table of n, a(n) for n = 1..10000</a>
%p N:= 1000: # for terms <= N
%p R:= NULL:
%p Cands:= [$2..N]:
%p while Cands <> [] do
%p r:= Cands[1];
%p R:= R,r;
%p Cands:= select(t -> t mod r^2 >= r, Cands[2..-1]);
%p od:
%p R; # _Robert Israel_, Sep 05 2024
%o (Python3)
%o from math import sqrt
%o length=100
%o s=list(range(2,length))
%o for p in range(int(sqrt(length))):
%o x = s[p]
%o if x==0 : continue
%o for i,e in enumerate(s):
%o if e>x and e%(x*x)<x:
%o s[i]=0 # mark sieved values as zero
%o result =[j for j in s if j!=0] # remove zeros
%o print(result)
%o (PARI) seq(n)={my(a=vector(n), k=1); for(n=1, #a, while(1, k++; my(f=1); for(i=1, n-1, if(k%a[i]^2<a[i], f=0; break)); if(f, a[n]=k; break))); a} \\ _Andrew Howroyd_, Sep 12 2020
%Y Cf. A000960, A000040.
%K nonn,easy
%O 1,1
%A _James Kilfiger_, Sep 12 2020 (suggested by student)
%E Terms a(29) and beyond from _Andrew Howroyd_, Sep 12 2020