login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A047949 a(n) is the largest m such that n-m and n+m are both primes, or -1 if no such m exists. 7

%I #58 Jul 01 2018 14:46:03

%S 0,0,1,2,1,4,5,4,7,8,7,10,9,8,13,14,13,12,17,16,19,20,19,22,21,20,25,

%T 24,23,28,29,28,27,32,31,34,35,34,33,38,37,40,39,38,43,42,41,30,47,46,

%U 49,50,49,52,53,52,55,54,53,48,51,50,45,62,61,64,63,62,67,68,67,66

%N a(n) is the largest m such that n-m and n+m are both primes, or -1 if no such m exists.

%C A067076 is a subsequence of this sequence: when 2m+3 is prime a(m+3) = m. Moreover, it is the subsequence of records (maximal increasing subsequence): let m=a(n), with p=n-m and q=p+2m both odd primes > 3; now 3+2(m+(p-3)/2)=q and hence a(3+m+(p-3)/2) >= m+(p-3)/2 > m = a(n) but 3+m+(p-3)/2 < n. - _Jason Kimberley_, Aug 30 2012 and Oct 10 2012

%C Goldbach's conjecture says a(n) >= 0 for all n. - _Robert Israel_, Apr 15 2015

%C a(n) is the Goldbach partition of 2n which results in the maximum spread divided by 2. - _Robert G. Wilson v_, Jun 18 2018

%H T. D. Noe, <a href="/A047949/b047949.txt">Table of n, a(n) for n = 2..10000</a>

%H OEIS (Plot 2), <a href="/plot2a?name1=A067076&amp;name2=A098090&amp;tform1=untransformed&amp;tform2=untransformed&amp;shift=0&amp;radiop1=xy&amp;drawpoints=true">A067076 vs A098090</a> (n-m=3). - _Jason Kimberley_, Oct 01 2012

%F a(n) = n - A020481(n).

%F a(n) = (A020482(n) - A020481(n))/2. - _Gionata Neri_, Apr 15 2015

%e 49-30=19 and 49+30=79 are primes, so a(49)=30.

%p a:= proc(n)

%p local k;

%p for k from n - 1 to 0 by -2 do

%p if isprime(n+k) and isprime(n-k) then return(k) fi

%p od:

%p -1

%p end proc:

%p 0, seq(a(n),n=3..1000); # _Robert Israel_, Apr 16 2015

%t a[2] = a[3] = 0; a[n_] := (For[m = n - 2, m >= 0, m--, If[PrimeQ[n - m] && PrimeQ[n + m], Break[]]]; m); Table[a[n], {n, 2, 100}] (* _Jean-François Alcover_, Sep 04 2013 *)

%t lm[n_]:=Module[{m=n-2},While[!AllTrue[n+{m,-m},PrimeQ],m--];m]; Join[{0,0}, Array[ lm,70,4]] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Dec 03 2014 *)

%t f[n_] := Block[{q = 2}, While[q <= n && !PrimeQ[2n -q], q = NextPrime@ q]; n - q]; Array[f, 72, 2] (* _Robert G. Wilson v_, Jun 18 2018 *)

%o (PARI) a(n) = {if (n==2 || n==3, return (0)); my(m = 1, lastm = -1, do = 1); while (do, if (isprime(n-m) && isprime(n+m), lastm = m); m++; if (m == n - 1, do = 0);); return (lastm);} \\ _Michel Marcus_, Jun 09 2013

%o (PARI) a(n)=if(n<4,0,forprime(p=3,n-1,if(isprime(2*n-p),return(n-p)));-1) \\ _Ralf Stephan_, Dec 29 2013

%o (Haskell)

%o a047949 n = if null qs then -1 else head qs where

%o qs = [m | m <- [n, n-1 .. 0], a010051' (n+m) == 1, a010051' (n-m) == 1]

%o -- _Reinhard Zumkeller_, Nov 02 2015

%Y Cf. A047160, A067076, A182138.

%Y Cf. A020481.

%Y Cf. A010051.

%K easy,nice,nonn

%O 2,4

%A _Lior Manor_

%E Corrected by _Harvey P. Dale_, Dec 21 2000

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 04:38 EDT 2024. Contains 371696 sequences. (Running on oeis4.)