OFFSET
2,2
COMMENTS
Apparently a(n) exists for any n > 1.
Smallest primes p with corresponding values of even d are {p,d}: {7,2}, {11,4}, {17,6}, {31,8}, {41,10}, {73,12}, {61,14}, {167,16}, {127,18}, {271,20}, {263,22}, {223,24}, {307,26}, {227,28}, {431,30}, {919,32}, {941,34}, {857,36}, {877,38}.
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 2..10000
EXAMPLE
a(3)=3 because p=prime(3)=5 and both 5-3 and 5+6 are prime.
a(5)=4 because p=prime(5)=11, and d cannot be 2 because 11-2 is not prime (and 11+4 is composite as well) while for d=4, both 11-4 and 11+8 are prime.
a(7)=6 because p=17, d cannot be 2 because both 17-2 and 17+4 are composite, d cannot be 4 because though 17-4 is prime but 17+8 is composite, finally d is 6 because both 17-6 and 17+12 are prime.
MATHEMATICA
s={3}; Do[p=Prime[k]; Do[If[PrimeQ[p-d]&&PrimeQ[p+2*d], s={s, d}; Break[]], {d, 2, p-3, 2}], {k, 4, 200}]; s=Flatten[s]
PROG
(PARI) a(n, p=prime(n))=my(q=p); while(q=precprime(q-1), if(isprime(3*p-2*q), return(p-q))); -1 \\ Charles R Greathouse IV, Jun 04 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Zak Seidov, Jun 03 2015
STATUS
approved