login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Least k>0 such that n-k and n+k are both primes.
28

%I #56 Sep 08 2022 08:45:10

%S 1,2,1,4,3,2,3,6,1,6,3,2,3,6,1,12,3,2,9,6,5,6,3,4,9,12,1,12,9,4,3,6,5,

%T 6,9,2,3,12,1,24,3,2,15,6,5,12,3,8,9,6,7,12,3,4,15,12,1,18,9,4,3,6,5,

%U 6,15,2,3,12,1,6,15,4,3,6,5,18,9,2,15,24,5,12,3,14,9,18,7,12,9,4,15,6,7,30,9

%N Least k>0 such that n-k and n+k are both primes.

%C The existence of k>0 for all n >= 4 is equivalent to the strong Goldbach Conjecture that every even number >= 8 is the sum of two distinct primes.

%C n and k are coprime, because otherwise n + k would be composite. So the rational sequence r(n) = a(n)/n = k/n is injective. - _Jason Kimberley_, Sep 03 and 21 2011

%C Because there are arbitrarily many composites from m!+2 to m!+m, there are also arbitrarily large a(n) but they increase very slowly. The twin prime conjecture implies that infinitely many a(n) are 1. - _Juhani Heino_, Apr 09 2020

%H Klaus Brockhaus, <a href="/A082467/b082467.txt">Table of n, a(n) for n = 4..5000</a>

%H OEIS (Plot 2), <a href="/plot2a?name1=A082467&amp;name2=A000027&amp;tform1=log+base+10&amp;tform2=untransformed&amp;shift=0&amp;radiop1=ratio&amp;drawpoints=true">log_10(A082467(n)/n) vs n </a>

%H J. S. Kimberley, <a href="/wiki/User:Jason_Kimberley/A082467">A082467</a>

%F A078496(n)-a(n) = A078587(n)+a(n) = n.

%e n=10: k=3 because 10-3 and 10+3 are both prime and 3 is the smallest k such that n +/- k are both prime.

%p A082467 := proc(n) local k; k := 1+irem(n,2);

%p while n > k do if isprime(n-k) then if isprime(n+k)

%p then RETURN(k) fi fi; k := k+2 od; print("Goldbach erred!") end:

%p seq(A082467(i),i=4..90); # _Peter Luschny_, Sep 21 2011

%t f[n_] := Block[{k}, If[OddQ[n], k = 2, k = 1]; While[ !PrimeQ[n - k] || !PrimeQ[n + k], k += 2]; k]; Table[ f[n], {n, 4, 98}] (* _Robert G. Wilson v_, Mar 28 2005 *)

%o (PARI) a(n)=if(n<0,0,k=1; while(isprime(n-k)*isprime(n+k) == 0,k++); k)

%o (Magma) A082467 := func<n|exists(r){m:m in[1..n-2]|IsPrime(n-m) and IsPrime(n+m)} select r else-1>; [A082467(n):n in [4..98]]; // _Jason Kimberley_, Sep 03 2011

%Y Cf. A087695, A087696, A087697, A087678, A087679, A087680, A087681, A087682, A087683, A087711.

%Y Cf. A129301 (records), A129302 (where records occur).

%Y Cf. A047160 (allows k=0).

%Y Cf. A078611 (subset for prime n).

%K nonn

%O 4,2

%A _Benoit Cloitre_, Apr 27 2003

%E Entries checked by _Klaus Brockhaus_, Apr 08 2007