login
a(n) = smallest prime p such that 2n + p^2 is another prime, or 0 if no such prime exists.
11

%I #17 Apr 19 2015 03:51:06

%S 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,

%T 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,

%U 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

%N a(n) = smallest prime p such that 2n + p^2 is another prime, or 0 if no such prime exists.

%C For numbers n such that a(n) = 0 see A138685.

%H Alois P. Heinz, <a href="/A138479/b138479.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Near-SquarePrime.html">Near-Square Prime</a>

%e 11=2+3^2 hence a(1)=3,

%e 13=4+3^2 hence a(2)=3,

%e 31=6+5^2 hence a(3)=5.

%p a:= proc(n) local p;

%p if irem(n, 3)=1 and not isprime(2*n+9) then 0

%p else p:=2;

%p do p:= nextprime(p);

%p if isprime(2*n+p^2) then return p fi

%p od

%p fi

%p end:

%p seq(a(n), n=1..100); # _Alois P. Heinz_, Jun 16 2014

%t 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 *)

%t 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

%Y Cf. A002373, A020481, A049613, A059324 (?).

%K nonn

%O 1,1

%A Philippe LALLOUET (philip.lallouet(AT)orange.fr), Mar 20 2008

%E More terms from _Artur Jasinski_ and _Farideh Firoozbakht_, Mar 26 2008