OFFSET
1,1
COMMENTS
a(n) is the least prime p of the form (q^2-(n+1))/n where q is a prime, or 0 if there is no such p.
If n+1 is prime, then a(n) <= n+1 as n*(n+1+1)+1 = (n+1)^2 is the square of a prime.
If n+1 = r^2 is a square, q^2-(n+1) = (q-r)*(q+r), so in order for p = (q-r)*(q+r)/n to be prime we need at least one of q-r and q+r to be a divisor of n. In particular, in this case we have q <= r+n. This can be used to show that a(n) = 0 for n = 143, 288, 323, 575, 728, 899, ....
Conjecture: all cases where a(n) = 0 arise in this way.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(5) = 23 because 23 is prime, 5*(23+1)+1 = 121 = 11^2, and 11 is prime, and no prime < 23 works.
MAPLE
f:= proc(n) local j, q, p, M, qmax;
if issqr(n+1) then qmax:= n+sqrt(n+1) else qmax:= infinity fi;
M:=sort(map(t -> rhs(op(t)), [msolve(q^2-1, n)]));
for j from 0 do
for m in M do
q:= j*n+m;
if q > qmax then return 0 fi;
if isprime(q) then
p:= (q^2-1)/n - 1;
if isprime(p) then return p fi
fi od od
end proc:
f(1):= 2:
map(f, [$1..100]);
PROG
(PARI) a(n) = my(p=2, r); while (!(issquare(n*(p+1)+1, &r) && isprime(r)), p=nextprime(p+1)); p; \\ Michel Marcus, May 04 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, May 03 2022
STATUS
approved