OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
a(n)*(n+1)-n = A350517(n)^2.
EXAMPLE
a(4) = 73 because 73 is prime, 73*(4+1)-4 = 361 = 19^2 where 19 is prime, and no smaller prime than 73 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 q fi
od od:
end proc:
map(g, [$1..100]);
MATHEMATICA
a[n_] := Module[{q = 2, p}, While[! IntegerQ[(p = Sqrt [q*(n + 1) - n])] || ! PrimeQ[p], q = NextPrime[q]]; q]; Array[a, 70] (* Amiram Eldar, Jan 03 2022 *)
PROG
(PARI) a(n) = my(q=2, p); while(! (issquare(q*(n+1)-n, &p) && isprime(p)), q = nextprime(q+1)); q; \\ Michel Marcus, Jan 03 2022
(Python)
from sympy import integer_nthroot, isprime, nextprime
def A350518(n):
q = 2
while True:
a, b = integer_nthroot(q*(n+1)-n, 2)
if b and isprime(a):
return q
q = nextprime(q) # Chai Wah Wu, Jan 04 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Jan 02 2022
STATUS
approved