OFFSET
0,1
EXAMPLE
For prime 43, 43 + 4 and 43 + 36 are prime but not 43 + 30^2.
PROG
(PARI) psq(n)=my(P=1); forprime(p=2, prime(n), P*=p); P^2;
isokpsq(p, n) = {for (k=1, n, if (!isprime(p+psq(k)), return (0)); ); if (!isprime(p+psq(n+1)), return (1)); }
a(n) = {p = 2; while (!isokpsq(p, n), p = nextprime(p+1)); p; } \\ Michel Marcus, May 04 2015
(PARI) allprime(v, n=0)=for(i=1, #v, if(!isprime(v[i]+n), return(0))); 1
a(n)=if(n<2, return(n+2)); my(t=4, v=vector(n-1, i, t*=prime(i+1)^2), p=2); t*=prime(n+1)^2; forprime(q=3, , if(q-p==4 && allprime(v, p) && !isprime(t+p), return(p)); p=q) \\ Charles R Greathouse IV, May 05 2015
CROSSREFS
KEYWORD
hard,nonn
AUTHOR
Fred Schneider, Apr 25 2015
EXTENSIONS
a(13)-a(14) from Fred Schneider, May 16 2015
STATUS
approved