%I #17 Jan 17 2026 12:56:04
%S 3,9,15,54,290,987,4530,21481,58554,60967,136457,136456,673393,
%T 1254204,1254203,7709873,21357254,21357253,25813465,25813464,39500858,
%U 39500857,947438661,947438660,947438659,5703167679,5703167678,16976360924,68745739764,117327812949,198156183037
%N a(n) is the least k such that the residues mod 3 of the primes prime(k), prime(k+1), ... comprise a string of n 2's followed by 1.
%e The primes mod 3 are A039701 = (2, 0, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 1, 2,...), in which (2,1) first appears in position 3, and (2,2,1) first occurs in position 9.
%t t = Table[Mod[Prime[nn], 3], {nn, 10^8}]; (* A039701 *)
%t u = Map[SequencePosition[t, Flatten[Join[{ConstantArray[2, #], 1}]], 1] &, Range[21]]
%t Table[First[Flatten[u[[n]]]], {n, 1, 21}]
%t (* _Peter J. C. Moses_, Dec 11 2025 *)
%o (Python)
%o from sympy import nextprime
%o from itertools import count, islice
%o def agen(NN=10000): # generator of terms for n <= NN
%o n, pk, residues = 1, 1, "X"*NN
%o for k in count(1):
%o pk = nextprime(pk)
%o resk = pk%3
%o if resk == 1:
%o while residues.endswith("2"*n) and n <= NN:
%o yield k-n
%o n += 1
%o residues = residues[1:] + str(resk)
%o print(list(islice(agen(), 12))) # _Michael S. Branicky_, Jan 11 2026
%Y Cf. A390511, A391807, A392104.
%K nonn
%O 1,1
%A _Clark Kimberling_, Jan 05 2026
%E a(22)-a(27) from _Michael S. Branicky_, Jan 11 2026
%E a(28)-a(31) from _Jinyuan Wang_, Jan 16 2026