OFFSET
1,4
COMMENTS
Goldbach's conjecture implies that a(n) is defined for all n. - David Wasserman, May 31 2007
LINKS
David Wasserman, Table of n, a(n) for n = 1..250
EXAMPLE
a(4)=13 because prime(4)=7, 7# = 2*3*5*7 = 210, and 210 - 13 and 210 + 13 are primes.
MATHEMATICA
pc[n_]:=Module[{x=0, i=0}, Do[If[PrimeQ[n-i]&&PrimeQ[n+i], x=i; Break[]], {i, 9!}]; x]; r=2; lst={}; Do[p=Prime[n]; r*=p; AppendTo[lst, pc[r]], {n, 2, 2*4!}]; lst (* Vladimir Joseph Stephan Orlovsky, Jun 14 2009 *)
sk[n_]:=Module[{k=0}, While[!PrimeQ[n+k]||!PrimeQ[n-k], k++]; k]; sk/@ FoldList[ Times, Prime[Range[50]]] (* Harvey P. Dale, Apr 03 2022 *)
PROG
(Python)
from sympy import isprime, prime, primerange
def aupton(terms):
phash, alst = 2, [0]
for p in primerange(3, prime(terms)+1):
phash *= p
for k in range(1, phash//2):
if isprime(phash-k) and isprime(phash+k): alst.append(k); break
return alst
print(aupton(46)) # Michael S. Branicky, May 29 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, May 21 2004
EXTENSIONS
More terms from Don Reble, May 27 2004
STATUS
approved