OFFSET
2,1
COMMENTS
Essentially the same as A002374, which is the main entry for this sequence. - Franklin T. Adams-Watters, Jan 25 2010
Well defined only under the assumption that the yet unproved Goldbach conjecture holds, which states that any even N = 2n > 2 has a decomposition as sum of two primes. - M. F. Hasler, May 03 2019
FORMULA
a(n) = n - A047160(n). - Jason Kimberley, Aug 31 2011
a(n) = n if and only if n is prime, i.e., n in A000040. - M. F. Hasler, May 03 2019
EXAMPLE
From M. F. Hasler, May 03 2019: (Start)
For n = 2, the largest prime p <= n is p = 2, and q := 2n - p = 4 - 2 = 2 is also prime, whence a(2) = 2. We see that whenever n is prime, we will have a(n) = p = q = n.
For n = 4, the largest prime p <= n is p = 3, and q := 2n - p = 8 - 3 = 5 is also prime, whence a(4) = p = 3.
For n = 8, the largest prime less than n is p' = 7, but 2n - p' = 16 - 7 = 9 is not prime, so we have to go to the next smaller prime p = 5 and now q := 2n - p = 16 - 5 = 11 is also prime, whence a(8) = p = 5. (End)
MATHEMATICA
f[n_] := Block[{p = n/2}, While[ !PrimeQ[p] || !PrimeQ[n - p], p-- ]; p]; Table[ f[n], {n, 4, 146, 2}]
PROG
(PARI) a(n) = {my(p = precprime(n)); while (!isprime(2*n-p), p = precprime(p-1)); p; } \\ Michel Marcus, Oct 22 2016
(PARI) A112823(n)=forprime(q=n, 2*n, isprime(2*n-q)&&return(2*n-q)) \\ M. F. Hasler, May 03 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert G. Wilson v, Sep 05 2005
STATUS
approved