Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #14 May 13 2022 05:21:07
%S 2,3,7,5,23,3,23,2,31,11,47,3,479,11,7,2,263,19,71,5,7,23,839,11,887,
%T 107,103,5,1031,3,3119,29,239,131,23,7,599,599,71,2,167,3,17159,11,7,
%U 47,9239,5,191,443,199,53,839,211,311,2,23,59,2111,5,2207,59,79,251,263,7,2399,149,31,11
%N a(n) is the least prime p such that n*(p+1)+1 is the square of a prime, or 0 if there is no such p.
%C 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.
%C 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.
%C 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, ....
%C Conjecture: all cases where a(n) = 0 arise in this way.
%H Robert Israel, <a href="/A351494/b351494.txt">Table of n, a(n) for n = 1..10000</a>
%e a(5) = 23 because 23 is prime, 5*(23+1)+1 = 121 = 11^2, and 11 is prime, and no prime < 23 works.
%p f:= proc(n) local j,q,p,M,qmax;
%p if issqr(n+1) then qmax:= n+sqrt(n+1) else qmax:= infinity fi;
%p M:=sort(map(t -> rhs(op(t)), [msolve(q^2-1, n)]));
%p for j from 0 do
%p for m in M do
%p q:= j*n+m;
%p if q > qmax then return 0 fi;
%p if isprime(q) then
%p p:= (q^2-1)/n - 1;
%p if isprime(p) then return p fi
%p fi od od
%p end proc:
%p f(1):= 2:
%p map(f, [$1..100]);
%o (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
%K nonn
%O 1,1
%A _J. M. Bergot_ and _Robert Israel_, May 03 2022