cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A112823 Greatest p less than or equal to n with p and q both prime, p+q = 2n.

Original entry on oeis.org

2, 3, 3, 5, 5, 7, 5, 7, 7, 11, 11, 13, 11, 13, 13, 17, 17, 19, 17, 19, 13, 23, 19, 19, 23, 23, 19, 29, 29, 31, 23, 29, 31, 29, 31, 37, 29, 37, 37, 41, 41, 43, 41, 43, 31, 47, 43, 37, 47, 43, 43, 53, 47, 43, 53, 53, 43, 59, 59, 61, 53, 59, 61, 59, 61, 67, 53, 67, 67, 71, 71, 73
Offset: 2

Views

Author

Robert G. Wilson v, Sep 05 2005

Keywords

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

Examples

			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)
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{p = n/2}, While[ !PrimeQ[p] || !PrimeQ[n - p], p-- ]; p]; Table[ f[n], {n, 4, 146, 2}]
  • 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

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