login
A138479
a(n) = smallest prime p such that 2n + p^2 is another prime, or 0 if no such prime exists.
11
3, 3, 5, 3, 3, 5, 3, 5, 5, 3, 3, 7, 0, 3, 7, 3, 3, 5, 3, 7, 5, 3, 5, 5, 3, 3, 5, 0, 3, 7, 3, 3, 29, 0, 3, 5, 3, 5, 5, 3, 5, 5, 0, 3, 7, 3, 3, 19, 3, 3, 5, 3, 5, 7, 0, 5, 5, 0, 3, 11, 3, 5, 5, 3, 3, 5, 0, 11, 5, 3, 3, 7, 0, 3, 7, 0, 3, 5, 3, 11, 7, 3, 5, 5, 3, 3, 5, 0, 7, 7, 3, 3, 5, 3, 3, 7, 0, 11, 5, 0
OFFSET
1,1
COMMENTS
For numbers n such that a(n) = 0 see A138685.
LINKS
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