Function Repository Resource:

LargestPrimeGap

Source Notebook

Give the greatest gap between the primes up to the argument

Contributed by: Wolfram Staff

ResourceFunction["LargestPrimeGap"][arg]

gives the largest difference between primes up to arg, which must be at least 3.

Examples

Basic Examples (3) 

Here are the primes up to 13:

In[1]:=
Prime /@ Range@PrimePi@13
Out[1]=

The largest gap is between 7 and 11:

In[2]:=
ResourceFunction["LargestPrimeGap"][13]
Out[2]=

The function is nondecreasing:

In[3]:=
ListLinePlot[ResourceFunction["LargestPrimeGap"] /@ Range[1000]]
Out[3]=

Although the gaps are unbounded, they rise slowly:

In[4]:=
Map[ResourceFunction["LargestPrimeGap"], 10^Range[7]]
Out[4]=

Publisher

George Beck

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 17 April 2019

License Information