What is the lowest arithmetic sequence of positive prime integers that has 3 terms? 5 terms? 8 terms?
What is the constant difference for the lowest N positive prime integers in arithmetic sequence?
What would the first term be for such a sequence?
(A prime sequence is "lowest" if the average of its terms is the lowest. If any are tied then it is the one with the smallest starting term.)
I wrote a short program to look for such sequences (sorry about the indenting -- one of these days I'll get around to figuring out how to do HTML in this window):
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_PRIME 1000000
main()
{
char *isprime;
int i,j,k,step,count,best;
isprime = (char *) malloc((MAX_PRIME+2)*sizeof(char));
memset(isprime,1,(MAX_PRIME+2)*sizeof(char));
isprime[0] = isprime[1] = 0;
fprintf(stderr,"memory initialized\n");
for(i=2; i<MAX_PRIME; i++) {
if(!isprime[i]) continue;
for(j=2*i; j
isprime[j] = 0;
}
fprintf(stderr,\"primes found\n\");
/*
* Now the tricky part: for each prime, check all following primes
* as the possible start of an arithmetic sequence. Determine the
* length of the resulting sequence, and print it out if it is > best
*/
best=0;
for(i=2; i<MAX_PRIME; i++) {
if(!isprime[i]) continue;
for(j=i+1; j
if(!isprime[j]) continue;
step = j-i;
count=2;
for(k=j+step; k
count++;
if(count > best) {
best=count;
printf("Found sequence of length %d starting at %d:\n",count,i);
for(k=0; k
printf("%8d",i+k*step);
printf("\n");
}
}
}
}
The output (sequences with terms smaller than 10^6) is:
Found sequence of length 2 starting at 2:
2 3
Found sequence of length 3 starting at 3:
3 5 7
Found sequence of length 5 starting at 5:
5 11 17 23 29
Found sequence of length 6 starting at 7:
7 37 67 97 127 157
Found sequence of length 7 starting at 7:
7 157 307 457 607 757 907
Found sequence of length 9 starting at 17:
17 6947 13877 20807 27737 34667 41597 48527 55457
Found sequence of length 10 starting at 199:
199 409 619 829 1039 1249 1459 1669 1879 2089
Found sequence of length 13 starting at 4943:
4943 65003 125063 185123 245183 305243 365303 425363 485423 545483 605543 665603 725663