In this question a user asks for an arithmetic progression
$$a, a+d, a+2d,\cdots, a+(n-1)d$$
for $a=101$ and $n=6$ such that all $a+id$ are prime numbers.
$3990$ is such a $d$ and it was found by a Haskell program by Wolfram published as answer to this question.
The sequence
$$7,37,67,97,127,157$$
for $n=6$ and $a=7$ is published in a comment by lulu to the question.
For $a=199$ this answer by Dietrich Burde shows the sequence $$a_k=199+210k, k=0,\cdots,9$$ which gives $$199,409,619,829,1039,1249,1459,1669,1879,2089, 199,409,619,829,1039,1249,1459,1669,1879,2089 $$
The Green-Tao-Theorm states that there are aritmethic progressions of arbitrary length that contain only primes.
The following Python program that uses the same algorithm as the Haskell program in the referenced post finds $d=3990$ immediately on my notebook.
def is_prime(n):
# check by trial division if n is prime
if n<=1:
return(False)
else:
for i in range(2,int(n**.5)+1,2):
if n%i==0:
return(False)
else:
return(True)
def find_d(a,n):
# for d=1,2,3,... test if the arithmetic progression
# a+d, a+2*d, …, a+(n-1)*d contains only primes
d=1
while True:
# test arithmetic progression for the next d
# if an element is not prime, you can skip
# this arithmetic progression and
# check the next d
# if an approprate t is found then return it
# and stop
d+=1
all_are_prime=True
for i in range(1,n):
if not is_prime(a+i*d):
all_are_prime=False
break
if all_are_prime:
return(d)
I ran it for larger $d$ and found the following $d$ that are minimal for $n$.
n d size sec
6 3990 5*10^3 0
7 1683990 10^6 16
8 3227070 5*10^6 43
9 9649080 10^7 160
Running this program with argument §n=10$ didn't give a result within 6 hours, and so I aborted the program.
I ran another program that calculated the numbers $d=54153939840$, $d=785714631660$, $d=169346689470$ for $n=10$. But I found out that the program has some bugs so I am not sure if $d=54153939840$ is the smallest number for $n=10$.
My Question: For $a=101$ how can I calculate $d$ efficiently for $n=10$ and larger $n$ and what is the expected number of operation the algorithm needs. Especially if a search algorithm is involved as in the program above this means what is the expected size of the smallest $d$ for a given $n$?
I plan to post my solution to this question as soon I have found time to repair the program and write an answer.