OFFSET
1,1
EXAMPLE
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 (1,2) first appears in position 4, and (1,1,2) first occurs in position 11, so a(1) = 4 and a(2) = 11.
MATHEMATICA
t = Table[Mod[Prime[nn], 3], {nn, 10^8}]; (* A039701 *)
u = Map[SequencePosition[t, Flatten[Join[{ConstantArray[1, #], 2}]], 1] &, Range[21]]
Table[First[Flatten[u[[n]]]], {n, 1, 21}]
(* Peter J. C. Moses, Dec 11 2025 *)
PROG
(Python)
from sympy import nextprime
from itertools import count, islice
def agen(NN=10000): # generator of terms for n <= NN
n, pk, residues = 1, 1, "X"*NN
for k in count(1):
pk = nextprime(pk)
resk = pk%3
if resk == 2:
while residues.endswith("1"*n) and n <= NN:
yield k-n
n += 1
residues = residues[1:] + str(resk)
print(list(islice(agen(), 13))) # Michael S. Branicky, Jan 11 2026
CROSSREFS
KEYWORD
nonn
AUTHOR
Clark Kimberling, Jan 05 2026
EXTENSIONS
a(22)-a(25) from Michael S. Branicky, Jan 11 2026
a(26)-a(31) from Jinyuan Wang, Jan 16 2026
STATUS
approved
