OFFSET
1,1
COMMENTS
a(n)=0 or 2*sqrt(n)+1 for square n. Apparently the only cases where it is 2*sqrt(n)+1 are n=1, 4 and 9. - Ralf Stephan, Mar 30 2003, corrected by Robert Israel, Dec 07 2024
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
for n from 1 to 100 do
if issqr(n) then
r:= sqrt(n);
if isprime(2*r+1) and not assigned(S[2*r+1]) then R[n]:= 2*r+1; S[2*r+1]:= n else R[n] := 0 fi;
else
for k from ceil(sqrt(n)) do
if not assigned(S[k^2-n]) and isprime(k^2-n) then R[n]:= k^2-n; S[k^2-n]:= n; break fi;
od
fi;
od:
seq(R[i], i=1..100); # Robert Israel, Dec 06 2024
PROG
(PARI) v=vector(1000000); for(n=1, 100, f=0; forprime(p=2, 1000000, if(!v[p]&&issquare(p+n), f=p; break)); if(f, print1(f", "); v[f]=1, print1("0, ")));
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Sep 23 2002
EXTENSIONS
More terms from Ralf Stephan, Mar 30 2003
STATUS
approved