OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(3) = 11 because p = 11 is prime, the next prime is q = 13, d = 2, and p-3*d = 5, p+3*d = 17, q-3*d = 7, and q+3*d = 19 are prime; and this is the least prime that works.
MAPLE
f:= proc(n) local p, q, c;
q:= 2:
do
p:= q; q:= nextprime(q); d:= q-p;
if isprime(p-n*d) and isprime(p+n*d) and isprime(q-n*d) and isprime(q+n*d) then return p fi
od;
end proc:
map(f, [$1..100]);
MATHEMATICA
a[n_] := Module[{p = 2, q = 3, d = 1}, While[! AllTrue[{p - n*d, p + n*d, q - n*d, q + n*d}, # > 0 && PrimeQ[#] &], p = q; q = NextPrime[q]; d = q - p]; p]; Array[a, 55] (* Amiram Eldar, Sep 06 2022 *)
PROG
(Python)
from sympy import isprime, nextprime
def a(n):
p = nextprime(2*n); q = nextprime(p); d = q-p
while not all(isprime(t) for t in [p-n*d, p+n*d, q-n*d, q+n*d]):
p = q; q = nextprime(q); d = q-p
return p
print([a(n) for n in range(1, 56)]) # Michael S. Branicky, Sep 05 2022
CROSSREFS
KEYWORD
nonn,look
AUTHOR
J. M. Bergot and Robert Israel, Sep 05 2022
STATUS
approved