Function Repository Resource:

Goldbach

Source Notebook

Get all representations of an even integer as the sum of two primes

Contributed by: Enrique Zeleny

ResourceFunction["Goldbach"][n]

gives the even integer n represented as the sum of two primes.

Details and Options

The Goldbach conjecture states that any even integer greater than or equal to four can be expressed as the sum of two prime numbers.
There may be many such representations.

Examples

Basic Examples (4) 

Some representations:

In[1]:=
ResourceFunction["Goldbach"][64]
Out[1]=
In[2]:=
Table[{n, Row[#, "+"] & /@ ResourceFunction["Goldbach"][n]}, {n, 4, 50, 2}] // Grid
Out[2]=

The "Goldbach comet":

In[3]:=
ListPlot[Table[{n, Length[ResourceFunction["Goldbach"][n]]}, {n, 4, 2000, 2}]]
Out[3]=

The number of representations can be very large:

In[4]:=
Length[ResourceFunction["Goldbach"][1000000]]
Out[4]=

Timings to compute Goldbach:

In[5]:=
ListLinePlot[
 Table[First[Timing[ResourceFunction["Goldbach"][n]]], {n, 4, 1000, 2}], PlotRange -> All]
Out[5]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 25 February 2019

License Information