OFFSET
1,2
COMMENTS
As '2 is prime' and also '2 is one less than prime 3' (see A173919), there exist two subsequences with k = 2 elements in these APs of primes (see examples).
1. If d is an odd term, then d is in A040976 \ {0} with d = prime(m) - 2, for some m >= 2, and, for each such d, there exists only one longest possible AP of primes, and this AP is always: (2, prime(m)) = (2, d+2), so starts with 2. This subsequence corresponds to the first case: '2 is prime'.
2. If d is an even term, then d is in A360735 and the longest corresponding APs of primes are of the form (q, q+d) with q odd primes. This subsequence corresponds to the second case '2 is one less than prime 3'.
A342309(d) gives the first element of the smallest AP with 2 elements whose common difference is a(n) = d.
The two elements of these APs are not necessarily consecutive primes.
LINKS
FORMULA
m is a term iff A123556(m) = 2.
EXAMPLE
d = 1 is a term because the only longest AP of primes with common difference 1 is (2, 3) that has 2 elements because 4 is composite.
d = 3 is a term because the only longest AP of primes with common difference 3 is (2, 5) that has 2 elements because 8 is composite.
d = 5 is a term because the only longest AP of primes with common difference 5 is (2, 7) that has 2 elements because 12 is composite.
d = 16 is a term because the first longest APs of primes with common difference 16 are (3, 19), (7,23), (13, 29), ... that all have 2 elements; the first one that starts with A342309(16) = 3 is (3, 19).
d = 22 is a term because the first longest APs of primes with common difference 22 are (7, 29), (19, 41), (31, 53), ... that all have 2 elements; the first one that starts with A342309(22) = 7 is (7, 29).
MAPLE
filter := d -> irem(d, 2) = 0 and irem(d, 3) <> 0 and not isprime(3+d) or irem(d, 2) = 0 and irem(d, 3) <> 0 and isprime(3+d) and not isprime(3+2*d) or isprime(d+2) : select(filter, [$(1 .. 155)]);
MATHEMATICA
Select[Range[155], Mod[#, 2]==0 && Mod[#, 3]!=0 && !PrimeQ[3+#] || Mod[#, 2]==0 && Mod[#, 3]!=0 && PrimeQ[3+#] && !PrimeQ[3+2#] || PrimeQ[#+2] &] (* Stefano Spezia, Jan 08 2023 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Bernard Schott, Dec 30 2022
STATUS
approved