login
A391796
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.
3
3, 9, 15, 54, 290, 987, 4530, 21481, 58554, 60967, 136457, 136456, 673393, 1254204, 1254203, 7709873, 21357254, 21357253, 25813465, 25813464, 39500858, 39500857, 947438661, 947438660, 947438659, 5703167679, 5703167678, 16976360924, 68745739764, 117327812949, 198156183037
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 (2,1) first appears in position 3, and (2,2,1) first occurs in position 9.
MATHEMATICA
t = Table[Mod[Prime[nn], 3], {nn, 10^8}]; (* A039701 *)
u = Map[SequencePosition[t, Flatten[Join[{ConstantArray[2, #], 1}]], 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 == 1:
while residues.endswith("2"*n) and n <= NN:
yield k-n
n += 1
residues = residues[1:] + str(resk)
print(list(islice(agen(), 12))) # Michael S. Branicky, Jan 11 2026
CROSSREFS
KEYWORD
nonn
AUTHOR
Clark Kimberling, Jan 05 2026
EXTENSIONS
a(22)-a(27) from Michael S. Branicky, Jan 11 2026
a(28)-a(31) from Jinyuan Wang, Jan 16 2026
STATUS
approved