OFFSET
2,1
COMMENTS
The sequence starts at n=2 as there is no solution for n=1.
The primes are probable primes for n>23.
LINKS
Pierre CAMI, Table of n, a(n) for n = 2..350
Wikipedia, Consecutive primes in arithmetic progression
EXAMPLE
6^2+11=47, 6^2+11+6=53, 6^2+11+2*6=59 and 47, 53, 59 are consecutive primes
and k=11 is minimal (since although 6^2+5=41, 6^2+5+6=47, 6^2+5+2*6=53 are primes, they are not consecutive primes), so a(2)=11. (Example clarified by Jonathan Sondow, Dec 16 2013.)
MATHEMATICA
a[n_] := For[k = 1, True, k = k+2, p = 6^n+k; If[PrimeQ[p], q = NextPrime[p]; r = NextPrime[q]; g = q-p; If[g == r-q, Print["n = ", n, " k = ", k, " g = ", g, " ", {p, q, r}]; Return[k]]]]; Table[a[n], {n, 2, 100}] (* Jean-François Alcover, Dec 17 2013 *)
PROG
(PFGW & SCRIPT)
DIM n, 1
DIM i
DIM J
DIM k
DIM pp
DIMS t
OPENFILEOUT myf, a(n).txt
LABEL a
SET n, n+1
IF n>350 THEN END
SET i, -1
SET j, 0
SET k, 0
LABEL b
SET i, i+2
SETS t, %d, %d, %d, %d\,; n; i; j; k
SET pp, 6^n+i
PRP pp, t
IF ISPRP THEN GOTO c
GOTO b
LABEL c
SET j, j+2
SET pp, 6^n+i+j
SETS t, %d, %d, %d, %d\,; n; i; j; k
PRP pp, t
IF ISPRP THEN GOTO d
GOTO c
LABEL d
IF j%6==0 THEN GOTO e
SET i, i+j
SET j, 0
GOTO c
LABEL e
SET k, k+2
SETS t, %d, %d, %d, %d\,; n; i; j; k
SET pp, 6^n+i+j+k
PRP pp, t
IF ISPRP && k==j THEN GOTO h
IF ISPRP THEN GOTO f
GOTO e
LABEL f
IF k%6==0 THEN GOTO g
SET i, i+j+k
SET j, 0
SET k, 0
GOTO c
LABEL g
SET i, i+j
SET j, k
SET k, 0
GOTO e
LABEL h
WRITE myf, t
GOTO a
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierre CAMI, Dec 12 2013
STATUS
approved