login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A350517
a(n) is the least prime p such that p^2+n = q*(n+1) for some prime q.
2
3, 2, 3, 19, 5, 41, 3, 19, 11, 67, 5, 131, 13, 41, 17, 101, 17, 37, 11, 29, 109, 47, 5, 101, 53, 1619, 13, 173, 11, 311, 31, 23, 103, 181, 19, 149, 37, 53, 41, 491, 13, 947, 23, 71, 137, 659, 7, 97, 151, 67, 131, 953, 53, 131, 41, 151, 59, 353, 11, 487, 61, 127, 191, 79, 43, 4021, 67, 139, 29
OFFSET
1,1
COMMENTS
a(n) >= sqrt(n+2), with equality if and only if n+2 is the square of a prime.
LINKS
FORMULA
a(n)^2+n = (n+1)*A350518(n).
EXAMPLE
a(4) = 19 because 19 is prime and 19^2+4 = 365 = 73*(4+1) where 73 is prime, and no smaller prime than 19 works.
MAPLE
g:= proc(n) local p, M, a, m, q;
M:= sort(map(t -> rhs(op(t)), [msolve(p^2=1, n+1)]));
for a from 0 do
for m in M do
p:= a*(n+1)+m;
if not isprime(p) then next fi;
q:= (p^2+n)/(n+1);
if isprime(q) then return p fi
od od:
end proc:
map(g, [$1..100]);
MATHEMATICA
a[n_] := Module[{p = NextPrime[Floor[Sqrt[n + 2]] - 1], q}, While[! IntegerQ [(q = (p^2 + n)/(n + 1))] || ! PrimeQ[q], p = NextPrime[p]]; p]; Array[a, 70] (* Amiram Eldar, Jan 03 2022 *)
PROG
(PARI) isp(r) = (denominator(r)==1) && isprime(r);
a(n) = my(p=2); while (!isp((p^2+n)/(n+1)), p = nextprime(p+1)); p; \\ Michel Marcus, Jan 03 2022
(Python)
from sympy import isprime, nextprime
def A350517(n):
p = 2
while True:
a, b = divmod(p**2+n, n+1)
if not b and isprime(a):
return p
p = nextprime(p) # Chai Wah Wu, Jan 04 2022
CROSSREFS
Cf. A350518.
Sequence in context: A298594 A092950 A059239 * A123170 A253381 A091806
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Jan 02 2022
STATUS
approved