OFFSET
1,1
COMMENTS
For numbers n such that a(n) = 0 see A138685.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Near-Square Prime
EXAMPLE
11=2+3^2 hence a(1)=3,
13=4+3^2 hence a(2)=3,
31=6+5^2 hence a(3)=5.
MAPLE
a:= proc(n) local p;
if irem(n, 3)=1 and not isprime(2*n+9) then 0
else p:=2;
do p:= nextprime(p);
if isprime(2*n+p^2) then return p fi
od
fi
end:
seq(a(n), n=1..100); # Alois P. Heinz, Jun 16 2014
MATHEMATICA
a = {}; Do[ p = 0; While[ (! PrimeQ[ 2*n + Prime[ p + 1 ]2 ]) && (p < 1000), p++ ]; If[ p < 1000, AppendTo[ a, Prime[ p + 1 ] ], AppendTo[ a, 0 ] ], {n, 1, 150} ]; a (* Artur Jasinski, Mar 26 2008 *)
a[n_]:=If[Mod[n, 3]!=1, (For[m=1, !PrimeQ[2n+Prime[m]^2], m++ ]; Prime[m]), If[ !PrimeQ[2n+9], 0, 3]]; Table[a[n], {n, 100}] - Farideh Firoozbakht, Mar 28 2008
CROSSREFS
KEYWORD
nonn
AUTHOR
Philippe LALLOUET (philip.lallouet(AT)orange.fr), Mar 20 2008
EXTENSIONS
More terms from Artur Jasinski and Farideh Firoozbakht, Mar 26 2008
STATUS
approved