close
login
A396268
a(n) is the least prime p such that, if q is the next prime after p, (p mod n) > (q mod n) while (p mod k) <= (q mod k) for all k < n, or -1 of there is no such p.
0
-1, -1, 2, 3, 7, -1, 53, 2557, 1831, 7417, 241, -1, 211, 17761, 91873, 2971, 10531, 238801, 6581, 22193, 311041, 979651, 29641, 1205779, 912871, 535879, 2066329, 17689267, 159361, -1, 3728561, 44823187, 19020961, 746776801, 510187681, 4060716103, 28057681, 527049541, 1183533067
OFFSET
1,3
COMMENTS
a(n) = prime(k) for the least k such that A121889(k) = n, or -1 if there is no such k.
EXAMPLE
a(5) = 7 because 7 is prime, the next prime is 11, (7 mod 5) = 2 > (11 mod 5) = 1, while (7 mod k) <= (11 mod k) for k = 1, 2, 3 and 4.
a(6) = -1 because there are no such p. The only possibility for (p,q) mod 6 where p and q are primes > 6 and (p mod 6) > (q mod 6) is (5,1), but in that case (p mod 3) = 2 > (q mod 3) = 1.
MAPLE
V:= Vector(39):
check:= proc(m) local P, nP, Cands, i, j, D;
P:= select(t -> igcd(t, m) = 1, [$1 .. m-1]); nP:= nops(P);
Cands:= [seq(seq([P[i], P[j]], i=1..j-1), j=2..nP)];
D:= NumberTheory:-Divisors(m) minus {1, m};
ormap(c -> andmap(d -> (c[1] mod d) >= (c[2] mod d), D), Cands)
end proc:
g:= proc(a, b) local m;
for m from 2 do if (a mod m) > (b mod m) then return m fi od
end proc:
V[remove(check, [$1..39])] := -1:
q:= 2:
for x from 1 while has(V, 0) do
p:= q; q:= nextprime(q);
v:= g(p, q);
if v <= 39 and V[v] = 0 then V[v]:= p fi;
od:
convert(V, list);
CROSSREFS
Cf. A121889.
Sequence in context: A068960 A358969 A205129 * A236290 A105273 A174925
KEYWORD
sign,new
AUTHOR
Robert Israel, May 20 2026
STATUS
approved