%I #24 Dec 02 2016 19:59:47
%S 0,0,0,0,0,0,0,0,0,2,0,2,0,2,3,2,0,2,3,2,3,2,5,2,5,2,3,2,5,2,7,2,5,2,
%T 7,2,7,2,7,2,11,2,11,2,5,2,11,2,13,2,11,2,13,2,13,2,11,2,17,2,13,2,13,
%U 2,17,2,17,2,17,2,19,2,19,2,13,2,17,2,19,2,17,2,23,2,19,2,19,2,23,2,23,2,23,2,23,2,29,2,23,2,29,2,29,2,23,2,29,2,31,2,31,2,29,2,31,2,29,2,31,2,37
%N Largest p such that n = p + q + r where p < q < r are all prime, or 0 if no such primes p, q, r exist.
%C Empirically, a(n) >= 2 for all n >= 18. Since a(2n) = 2 unless it is zero, the terms with even indices are less interesting, and the terms with odd indices are listed in A278923.
%C For even n, the existence of the three primes reduces to a slightly strengthened* variant of Goldbach's conjecture. For odd n, is a slightly strengthened* variant of the weak (a.k.a. odd, or ternary) Goldbach conjecture, considered to be proved since 2013. (*) In both cases, the strengthening consists of requiring that the three primes must be distinct.
%C From _Robert G. Wilson v_, Dec 02 2016: (Start)
%C The first occurrence of the n-th prime: 10, 15, 23, 31, 41, 49, 59, 71, 83, 97, 109, 121, 131, 143, 159, 173, 187, 199, 211, 223, 235, 251, 269, 287, 301, 311, 319, 329, 349, 371, 395, 407, 425, 439, 457, 471, 487, 503, ..., .
%C Conjecture: primes appear in their natural order.
%H David W. Wilson, <a href="/A278922/b278922.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Go#Goldbach">Index entries for sequences related to Goldbach conjecture</a>
%F a(2n) = 2 (for n > 4), since one of the three primes must necessarily be even, and that can only be p = 2.
%F a(n) = 0 for n < 2 + 3 + 5 = 10, and for odd n < 3 + 5 + 7 = 15.
%t f[n_] := If[OddQ@n || n < 18, Block[{p = 0, q = 3, r = 5}, While[q < r, r = NextPrime@ q; While[r < n - q - 1, If[n < 2q + r && PrimeQ[n - r - q], p = Max[p, n - r - q]; Break[]]; r = NextPrime@ r]; q = NextPrime@ q]; p], 2]; Array[f, 121] (* _Robert G. Wilson v_, Dec 02 2016 *)
%o (PARI) a(n,p=if(bittest(n,0),n\3-1,3))=while(p=precprime(p-1),forprime(q=p+1,(n-p-1)\2,isprime(n-p-q)&&return(p)))
%Y Cf. A278923.
%Y Cf. A278373, complement of A056996.
%K nonn
%O 1,10
%A _M. F. Hasler_, Dec 01 2016