login
A391807
a(n) is the least k such that the residues mod 3 of the primes prime(k), prime(k+1),... include a string of n 1's followed by 2.
3
4, 11, 36, 273, 272, 271, 2209, 11199, 13718, 13717, 34369, 172147, 172146, 3094796, 3094795, 4308948, 12762142, 23902561, 72084958, 72084957, 72084956, 1052779162, 1052779161, 1857276774, 1857276773, 19398320447, 57446769095, 57446769094, 57446769093, 57446769092, 57446769091
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