Wolfram Research

Function Repository Resource:

Primorial

Source Notebook

Evaluate the primorial

Contributed by: Sander Huisman

ResourceFunction["Primorial"][n]

calculates the product of the primes up to n.

Details

Integer mathematical function, suitable for both symbolic and numerical manipulation.
For n1, the primorial is equal to 1.
For n2, the primorial is defined as , where pk is the kth prime and π(n) is PrimePi[n].
ResourceFunction["Primorial"] has the attribute Listable.

Examples

Basic Examples (2) 

Compute the 23# primorial:

In[1]:=
ResourceFunction["Primorial"][23]
Out[1]=

Compute a list of the first 15 primorials:

In[2]:=
ResourceFunction["Primorial"][Range[15]]
Out[2]=

Scope (1) 

For nonpositive numbers, the primorial is defined to be equal to 1:

In[3]:=
ResourceFunction["Primorial"][-4]
Out[3]=

Properties and Relations (2) 

Compare with the definition:

In[4]:=
With[{k = 7}, Product[Prime[j], {j, 1, PrimePi[k]}] == ResourceFunction["Primorial"][k]]
Out[4]=

The resource function ChebyshevTheta is the logarithm of the primorial:

In[5]:=
With[{k = 7}, Exp[ResourceFunction["ChebyshevTheta"][k]] == ResourceFunction["Primorial"][k]]
Out[5]=

Neat Examples (3) 

Evaluate the infinite primorial:

In[6]:=
Product[Prime[k], {k, 1, \[Infinity]}, Regularization -> "Dirichlet"]
Out[6]=
In[7]:=
ResourceFunction["Primorial"][\[Infinity]]
Out[7]=

Compare the growth rate of the primorial versus factorial:

In[8]:=
DiscretePlot[{ResourceFunction["Primorial"][n], Factorial[n]}, {n, 1, 50}, ScalingFunctions -> "Log", PlotLegends -> {"n#", "n!"}]
Out[8]=

Plot the differences between the factorial and the primorial up to n:

In[9]:=
ListLinePlot[
 Differences[
  Table[Log[n!/ResourceFunction["Primorial"][n]], {n, 1, 100, 1}]], Filling -> Axis]
Out[9]=

Resource History

Related Resources

License Information