%I #56 Feb 26 2023 17:42:05
%S 1,3,5,9,11,15,16,17,21,22,26,27,29,32,35,39,41,44,45,46,51,52,56,57,
%T 58,59,62,65,69,70,71,74,76,77,81,82,86,87,88,92,95,99,100,101,105,
%U 105,106,107,111,112,116,118,122,125,128,129,130,135,136,137,140,142,146,147,148,149,152,155
%N Integers d such that the longest possible arithmetic progression (AP) of primes with common difference d has only two elements.
%C 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).
%C 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'.
%C 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'.
%C A342309(d) gives the first element of the smallest AP with 2 elements whose common difference is a(n) = d.
%C The two elements of these APs are not necessarily consecutive primes.
%H Diophante, <a href="http://www.diophante.fr/problemes-par-themes/arithmetique-et-algebre/a1-pot-pourri/3940-a1880-np-en-pa">A1880. NP (Nombres Premiers) en PA (Progression Arithmétique)</a> (in French).
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Primes_in_arithmetic_progression">Primes in arithmetic progression</a>.
%H <a href="/index/Pri#primes_AP">Index entries for sequences related to primes in arithmetic progressions</a>.
%F m is a term iff A123556(m) = 2.
%e 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.
%e 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.
%e 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.
%e 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).
%e 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).
%p 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)]);
%t 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 *)
%Y Cf. A123556, A173919, A342309.
%Y Equals disjoint union of A040976 \ {0} and A360735.
%Y Longest AP of prime numbers with exactly k elements: A007921 (k=1), this sequence (k=2), A206037 (k=3), A359409 (k=4), A206039 (k=5), A359410 (k=6), A206041 (k=7), A360146 (k=10), A206045 (k=11)
%K nonn
%O 1,2
%A _Bernard Schott_, Dec 30 2022
|