OFFSET
1,1
COMMENTS
a(n) >= sqrt(n+2), with equality if and only if n+2 is the square of a prime.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
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
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Jan 02 2022
STATUS
approved