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.
%I A047160 #66 Nov 16 2024 16:27:00 %S A047160 0,0,1,0,1,0,3,2,3,0,1,0,3,2,3,0,1,0,3,2,9,0,5,6,3,4,9,0,1,0,9,4,3,6, %T A047160 5,0,9,2,3,0,1,0,3,2,15,0,5,12,3,8,9,0,7,12,3,4,15,0,1,0,9,4,3,6,5,0, %U A047160 15,2,3,0,1,0,15,4,3,6,5,0,9,2,15,0,5,12,3,14,9,0,7,12,9,4,15,6,7,0,9,2,3 %N A047160 For n >= 2, a(n) = smallest number m >= 0 such that n-m and n+m are both primes, or -1 if no such m exists. %C A047160 I have confirmed there are no -1 entries through integers to 4.29*10^9 using PARI. - _Bill McEachen_, Jul 07 2008 %C A047160 From _Daniel Forgues_, Jul 02 2009: (Start) %C A047160 Goldbach's Conjecture: for all n >= 2, there are primes (distinct or not) p and q s.t. p+q = 2n. The primes p and q must be equidistant (distance m >= 0) from n: p = n-m and q = n+m, hence p+q = (n-m)+(n+m) = 2n. %C A047160 Equivalent to Goldbach's Conjecture: for all n >= 2, there are primes p and q equidistant (distance >= 0) from n, where p and q are n when n is prime. %C A047160 If this conjecture is true, then a(n) will never be set to -1. %C A047160 Twin Primes Conjecture: there is an infinity of twin primes. %C A047160 If this conjecture is true, then a(n) will be 1 infinitely often (for which each twin primes pair is (n-1, n+1)). %C A047160 Since there is an infinity of primes, a(n) = 0 infinitely often (for which n is prime). %C A047160 (End) %C A047160 If n is composite, then n and a(n) are coprime, because otherwise n + a(n) would be composite. - _Jason Kimberley_, Sep 03 2011 %C A047160 From _Jianglin Luo_, Sep 22 2023: (Start) %C A047160 a(n) < primepi(n)+sigma(n,0); %C A047160 a(n) < primepi(primepi(n)+n); %C A047160 a(n) < primepi(n), for n>344; %C A047160 a(n) = o(primepi(n)), as n->+oo. (End) %C A047160 If -1 < a(n) < n-3, then a(n) is divisible by 3 if and only if n is not divisible by 3, and odd if and only if n is even. - _Robert Israel_, Oct 05 2023 %H A047160 T. D. Noe, <a href="/A047160/b047160.txt">Table of n, a(n) for n = 2..10000</a> %H A047160 Jason Kimberley, <a href="/wiki/User:Jason_Kimberley/A047160">Symmetrical plot of A047160</a> %F A047160 a(n) = n - A112823(n). %F A047160 a(n) = A082467(n) * A005171(n), for n > 3. - _Jason Kimberley_, Jun 25 2012 %e A047160 16-3=13 and 16+3=19 are primes, so a(16)=3. %t A047160 Table[k = 0; While[k < n && (! PrimeQ[n - k] || ! PrimeQ[n + k]), k++]; If[k == n, -1, k], {n, 2, 100}] %t A047160 smm[n_]:=Module[{m=0},While[AnyTrue[n+{m,-m},CompositeQ],m++];m]; Array[smm,100,2] (* _Harvey P. Dale_, Nov 16 2024 *) %o A047160 (UBASIC) 10 N=2// 20 M=0// 30 if and{prmdiv(N-M)=N-M,prmdiv(N+M)=N+M} then print M;:goto 50// 40 inc M:goto 30// 50 inc N: if N>130 then stop// 60 goto 20 %o A047160 (Magma) A047160:=func<n|exists(r){m:m in[0..n-2]|IsPrime(n-m)and IsPrime(n+m)}select r else-1>;[A047160(n):n in[2..100]]; // _Jason Kimberley_, Sep 02 2011 %o A047160 (Haskell) %o A047160 a047160 n = if null ms then -1 else head ms %o A047160 where ms = [m | m <- [0 .. n - 1], %o A047160 a010051' (n - m) == 1, a010051' (n + m) == 1] %o A047160 -- _Reinhard Zumkeller_, Aug 10 2014 %o A047160 (PARI) a(n)=forprime(p=n,2*n, if(isprime(2*n-p), return(p-n))); -1 \\ _Charles R Greathouse IV_, Jun 23 2017 %Y A047160 Cf. A001031, A002092, A002372, A002373, A002374, A002375, A014092, A025583, A035026, A047949, A071406, A082467, A102084, A103147, A112823, A155764, A155765, A177461, A078611, A010051, A045917, A325142. %K A047160 nonn,easy,nice %O A047160 2,7 %A A047160 _Lior Manor_ %E A047160 More terms from _Patrick De Geest_, May 15 1999 %E A047160 Deleted a comment. - _T. D. Noe_, Jan 22 2009 %E A047160 Comment corrected and definition edited by _Daniel Forgues_, Jul 08 2009