login
A257467
Smallest prime number p such that p + psq(1), p + psq(2), ... p + psq(n) are all prime but p+psq(n+1) is not. (psq(n) is the square of the primorial.)
2
2, 3, 43, 7, 163, 397, 5527, 454543, 615883, 142516687, 68967673, 57502725253, 37520993053, 2630665498987, 39809897510563
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