---
title: "PrimePi"
language: "en"
type: "Symbol"
summary: "PrimePi[x] gives the number of primes PrimePi[x] less than or equal to x."
keywords: 
- distribution of primes
- prime counting function
- prime count
- Deleglise-Rivat
- Eratosthenes
- Lagarias-Miller-Odlyzko
- Lehmer
- Legendre
- Meissel
- sieve
- pi
canonical_url: "https://reference.wolfram.com/language/ref/PrimePi.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Prime Numbers"
    link: "https://reference.wolfram.com/language/guide/PrimeNumbers.en.md"
  - 
    title: "Analytic Number Theory"
    link: "https://reference.wolfram.com/language/guide/AnalyticNumberTheory.en.md"
  - 
    title: "Multiplicative Number Theory"
    link: "https://reference.wolfram.com/language/guide/MultiplicativeNumberTheory.en.md"
  - 
    title: "Mathematical Functions"
    link: "https://reference.wolfram.com/language/guide/MathematicalFunctions.en.md"
  - 
    title: "Number Theory"
    link: "https://reference.wolfram.com/language/guide/NumberTheory.en.md"
  - 
    title: "Number Theoretic Functions"
    link: "https://reference.wolfram.com/language/guide/NumberTheoreticFunctions.en.md"
related_functions: 
  - 
    title: "Prime"
    link: "https://reference.wolfram.com/language/ref/Prime.en.md"
  - 
    title: "NextPrime"
    link: "https://reference.wolfram.com/language/ref/NextPrime.en.md"
  - 
    title: "RiemannR"
    link: "https://reference.wolfram.com/language/ref/RiemannR.en.md"
  - 
    title: "LogIntegral"
    link: "https://reference.wolfram.com/language/ref/LogIntegral.en.md"
  - 
    title: "Zeta"
    link: "https://reference.wolfram.com/language/ref/Zeta.en.md"
  - 
    title: "ZetaZero"
    link: "https://reference.wolfram.com/language/ref/ZetaZero.en.md"
  - 
    title: "EulerPhi"
    link: "https://reference.wolfram.com/language/ref/EulerPhi.en.md"
related_tutorials: 
  - 
    title: "Integer and Number Theoretic Functions"
    link: "https://reference.wolfram.com/language/tutorial/MathematicalFunctions.en.md#20170"
  - 
    title: "Implementation Notes: Numerical and Related Functions"
    link: "https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.en.md#12788"
---
# PrimePi

PrimePi[x] gives the number of primes $\pi (x)$ less than or equal to x.

## Details and Options

* ``PrimePi`` is also known as prime counting function.

* Mathematical function, suitable for both symbolic and numerical manipulation.

* $\pi (x)$ counts the prime numbers less than or equal to ``x``.

* $\pi (x)$ has the asymptotic expansion $x/\log (x)+x\left/\log ^2(x)\right.+2 x\left/\log ^3(x)\right.+\ldots$ as $x\to \infty$.

[image]

* The following option can be given:

|                    |                     |                                                   |
| ------------------ | ------------------- | ------------------------------------------------- |
| Method             | Automatic           | method to use                                     |
| ProgressReporting  | \$ProgressReporting | whether to report the progress of the computation |

* Possible settings for ``Method`` include:

|                  |                                           |
| ---------------- | ----------------------------------------- |
| "DelegliseRivat" | use the Deléglise–Rivat algorithm         |
| "Legendre"       | use the Legendre formula                  |
| "Lehmer"         | use the Lehmer formula                    |
| "LMO"            | use the Lagarias–Miller–Odlyzko algorithm |
| "Meissel"        | use the Meissel formula                   |
| "Sieve"          | use the sieve of Erastosthenes            |

---

## Examples (50)

### Basic Examples (3)

Compute the number of primes up to 15:

```wl
In[1]:= PrimePi[15]

Out[1]= 6
```

---

Plot the prime counting function:

```wl
In[1]:= Plot[PrimePi[x], {x, 0, 50}]

Out[1]= [image]
```

---

Find the leading asymptotic term for ``PrimePi`` at ``Infinity`` :

```wl
In[1]:= Asymptotic[PrimePi[x], x -> Infinity]

Out[1]= (x/Log[x])
```

### Scope (10)

#### Numerical Evaluation (5)

``PrimePi`` works over integers:

```wl
In[1]:= PrimePi[100]

Out[1]= 25
```

---

Rational numbers:

```wl
In[1]:= PrimePi[7 / 2]

Out[1]= 2
```

---

Real numbers:

```wl
In[1]:= PrimePi[15.25]

Out[1]= 6
```

---

``PrimePi`` works over large numbers:

```wl
In[1]:= PrimePi[10 ^ 15]

Out[1]= 29844570422669
```

---

``PrimePi`` threads over lists:

```wl
In[1]:= PrimePi[{3, 5, 17, 25}]

Out[1]= {2, 3, 7, 9}
```

#### Symbolic Manipulation (5)

The traditional mathematical notation for ``PrimePi`` :

```wl
In[1]:= PrimePi[x]//TraditionalForm

Out[1]//TraditionalForm= $$\pi (x)$$
```

---

Find a solution instance of equalities with ``PrimePi`` :

```wl
In[1]:= FindInstance[PrimePi[n] == 7, n, Integers]

Out[1]= {{n -> 17}}
```

---

Evaluate an integral:

```wl
In[1]:= Integrate[PrimePi[x ^ 2], {x, 0, 10}]

Out[1]= 250 - Sqrt[2] - Sqrt[3] - Sqrt[5] - Sqrt[7] - Sqrt[11] - Sqrt[13] - Sqrt[17] - Sqrt[19] - Sqrt[23] - Sqrt[29] - Sqrt[31] - Sqrt[37] - Sqrt[41] - Sqrt[43] - Sqrt[47] - Sqrt[53] - Sqrt[59] - Sqrt[61] - Sqrt[67] - Sqrt[71] - Sqrt[73] - Sqrt[79] - Sqrt[83] - Sqrt[89] - Sqrt[97]
```

---

Recognize the ``PrimePi`` function:

```wl
In[1]:= FindSequenceFunction[{0, 1, 2, 2, 3, 3, 4, 4, 4, 4}, n]

Out[1]= PrimePi[n]
```

---

Find asymptotic relations:

```wl
In[1]:= Asymptotic[PrimePi[x], x -> Infinity]

Out[1]= (x/Log[x])
```

Verify asymptotic relations:

```wl
In[2]:= AsymptoticEquivalent[PrimePi[x], LogIntegral[x], x -> Infinity]

Out[2]= True
```

### Options (6)

#### Method (5)

Specify the Legendre method to be used for counting primes [[MathWorld](http://mathworld.wolfram.com/LegendresFormula.html)]:

```wl
In[1]:= PrimePi[10 ^ 6, Method -> "Legendre"]

Out[1]= 78498
```

Compare the timing:

```wl
In[2]:= BarChart[Table[{First[AbsoluteTiming[PrimePi[10 ^ n]]], First[AbsoluteTiming[PrimePi[10 ^ n, Method -> "Legendre"]]]}, {n, 7, 11, .5}], ChartLegends -> {"Automatic", "Legendre"}]

Out[2]= [image]
```

---

Specify the Lehmer method to be used for counting primes [[MathWorld](http://mathworld.wolfram.com/LehmersFormula.html)]:

```wl
In[1]:= PrimePi[10 ^ 6, Method -> "Lehmer"]

Out[1]= 78498
```

Compare the timing:

```wl
In[2]:= BarChart[Table[{First[AbsoluteTiming[PrimePi[10 ^ n]]], First[AbsoluteTiming[PrimePi[10 ^ n, Method -> "Lehmer"]]]}, {n, 7, 11, .5}], ChartLegends -> {"Automatic", "Lehmer"}]

Out[2]= [image]
```

---

Specify the Deléglise–Rivat method to be used for counting primes:

```wl
In[1]:= PrimePi[10 ^ 6, Method -> "DelegliseRivat"]

Out[1]= 78498
```

Compare the timing:

```wl
In[2]:= BarChart[Table[{First[AbsoluteTiming[PrimePi[10 ^ n]]], First[AbsoluteTiming[PrimePi[10 ^ n, Method -> "DelegliseRivat"]]]}, {n, 7, 11, .5}], ChartLegends -> {"Automatic", "Deleglise-Rivat"}]

Out[2]= [image]
```

---

Specify the Meissel method to be used for counting primes [[MathWorld](http://mathworld.wolfram.com/MeisselsFormula.html)]:

```wl
In[1]:= PrimePi[10 ^ 6, Method -> "Meissel"]

Out[1]= 78498
```

Compare the timing:

```wl
In[2]:= BarChart[Table[{First[AbsoluteTiming[PrimePi[10 ^ n]]], First[AbsoluteTiming[PrimePi[10 ^ n, Method -> "Meissel"]]]}, {n, 7, 11, .5}], ChartLegends -> {"Automatic", "Meissel"}]

Out[2]= [image]
```

---

Specify the Lagarias–Miller–Odlyzko (LMO) to be used for counting primes:

```wl
In[1]:= PrimePi[10 ^ 6, Method -> "LMO"]

Out[1]= 78498
```

Compare the timing:

```wl
In[2]:= BarChart[Table[{First[AbsoluteTiming[PrimePi[10 ^ n]]], First[AbsoluteTiming[PrimePi[10 ^ n, Method -> "LMO"]]]}, {n, 7, 11, .5}], ChartLegends -> {"Automatic", "Lagarias-Miller-Odlyzko"}]

Out[2]= [image]
```

#### ProgressReporting (1)

By default, ``PrimePi`` does not report progress:

```wl
In[1]:= PrimePi[10 ^ 17 + 1]

Out[1]= 2623557157654233
```

With the setting ``ProgressReporting -> True``,  ``PrimePi`` shows the progress of the computation:

```wl
In[2]:= PrimePi[10 ^ 17 + 1, ProgressReporting -> True]

During evaluation of In[7]:= [image]
```

### Applications (22)

#### Basic Applications (7)

Visualize the ``PrimePi`` function:

```wl
In[1]:= Grid[Prepend[Table[{"10" ^ n, PrimePi[10 ^ n]}, {n, 1, 10}], {"x", "π(x)"}], ...]

Out[1]=
|         |           |
| ------- | --------- |
| "x"     | "π(x)"    |
| "10"    | 4         |
| "10"^2  | 25        |
| "10"^3  | 168       |
| "10"^4  | 1229      |
| "10"^5  | 9592      |
| "10"^6  | 78498     |
| "10"^7  | 664579    |
| "10"^8  | 5761455   |
| "10"^9  | 50847534  |
| "10"^10 | 455052511 |
```

---

Spiral of ``PrimePi`` :

```wl
In[1]:= ListPolarPlot[Table[{Mod[π / 2 - n 4π / 50, 2π], PrimePi[n]}, {n, 50}], ...]

Out[1]= [image]
```

---

Hexagonal prime spiral:

```wl
In[1]:= hexagonalSpiral[n_] := {Re[#], Im[#]}& /@ Fold[Join[#1, Last[#1] + Exp[I Pi / 3] ^ #2Range[#2 / 2]]&, {0}, Range[n]]

In[2]:= spiral = hexagonalSpiral[25];

In[3]:= primes = spiral[[Prime[Range[PrimePi[Length[spiral]]]]]];

In[4]:= ListPlot[spiral, ...]

Out[4]= [image]
```

---

``ContourPlot`` of the ``PrimePi`` function:

```wl
In[1]:= ListContourPlot[Table[{x = n, y = PrimePi[n]}, {n, 1, 25}]]

Out[1]= [image]
```

---

Plot the difference between ``RiemannR`` and the ``PrimePi`` function:

```wl
In[1]:= r = 0;c = -1;ListPolarPlot[{Table[{i * Pi / 8, x = RiemannR[i] - PrimePi[i];If[x > c, c = x;r = r + 1];PrimePi[i] * r / i}, {i, 1000}]}, Rule[...]]

Out[1]= [image]
```

---

Find all prime numbers less than or equal to 100:

```wl
In[1]:= Prime[Range[PrimePi[100]]]

Out[1]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
```

---

Count the number of primes in an interval:

```wl
In[1]:= primecount[{x_, y_}] := PrimePi[y + 1] - PrimePi[x - 1]

In[2]:= primecount[{5, 15}]

Out[2]= 4
```

#### Approximations (7)

Approximations to ``PrimePi`` :

```wl
In[1]:= PrimePi[5000]

Out[1]= 669

In[2]:= 5000 / Log[5000.]

Out[2]= 587.048

In[3]:= LogIntegral[5000.]

Out[3]= 684.281

In[4]:= RiemannR[5000.]

Out[4]= 668.946
```

Plot ``PrimePi`` compared with estimates:

```wl
In[5]:= Plot[{PrimePi[x], x / Log[x], LogIntegral[x], RiemannR[x]}, {x, 1.5, 100}, Rule[...]]

Out[5]= [image]
```

---

$\pi (x)$ is bounded below by $\frac{x}{\log (x)}$ and is bounded above by $\frac{x}{\log (x)-1.112}$ for $x$ greater than 3:

```wl
In[1]:= Plot[{x / Log[x], PrimePi[x], x / (Log[x] - 1.112)}, {x, 3, 100}, Rule[...]]

Out[1]= [image]
```

---

$\frac{ x}{H_x-3/2}$ is within $\approx 2$ of $\pi (x)$ for $50\leq x\leq 1000$ :

```wl
In[1]:= Plot[{(x/HarmonicNumber[x] - 3 / 2), PrimePi[x]}, {x, 50, 200}, Rule[...]]

Out[1]= [image]
```

---

$| \pi (x)-\text{li}(x)| <\frac{\sqrt{x} \log (x)}{8 \pi }$ for $x>2657$ if the Riemann hypothesis is true:

```wl
In[1]:= Plot[{Abs[PrimePi[x] - LogIntegral[x]], Sqrt[x]Log[x] / (8 * Pi)}, {x, 2657, 3000}, PlotLegends -> "Expressions"]

Out[1]= [image]
```

---

Count the prime numbers using ``EulerPhi`` :

```wl
In[1]:= primecount[x_] := Underoverscript[∑, k = 2, ⌊x⌋]⌊(EulerPhi[k]/k - 1)⌋

In[2]:= Table[primecount[n], {n, 0, 10}]

Out[2]= {0, 0, 1, 2, 2, 3, 3, 4, 4, 4, 4}

In[3]:= Table[PrimePi[n], {n, 0, 10}]

Out[3]= {0, 0, 1, 2, 2, 3, 3, 4, 4, 4, 4}
```

---

Compute ``PrimePi`` based on the Hardy–Wright formula:

```wl
In[1]:= primecount[x_] := Sum[Mod[(j - 2)!, j], {j, 4, x}]

In[2]:= Table[primecount[n], {n, 5, 10}]

Out[2]= {3, 3, 4, 4, 4, 4}

In[3]:= Table[PrimePi[n], {n, 5, 10}]

Out[3]= {3, 3, 4, 4, 4, 4}
```

---

Compute ``PrimePi`` using ``Accumulate`` :

```wl
In[1]:= Accumulate[Table[Boole[PrimeQ[n]], {n, 1, 10}]]

Out[1]= {0, 1, 2, 2, 3, 3, 4, 4, 4, 4}

In[2]:= Table[PrimePi[n], {n, 1, 10}]

Out[2]= {0, 1, 2, 2, 3, 3, 4, 4, 4, 4}
```

#### Number Theory (8)

Find twin primes up to $n$, i.e. pairs of primes of the form $(p,p+2)$ :

```wl
In[1]:= TwinPrimes[n_] := Pick[#, PrimeQ[# + 2]]&[Prime[Range[PrimePi[n]]]]

In[2]:= TwinPrimes[100]

Out[2]= {3, 5, 11, 17, 29, 41, 59, 71}

In[3]:= TwinPrimePi[n_] := Length[Pick[#, PrimeQ[# + 2]]]&[Prime[Range[PrimePi[n]]]]
```

Plot the sequence of twin primes and ``PrimePi`` :

```wl
In[4]:= ListStepPlot[{Table[TwinPrimePi[n], {n, 1, 100}], Table[PrimePi[n], {n, 1, 100}]}]

Out[4]= [image]
```

---

The $n$$$^{\text{th}}$$ Ramanujan prime is the smallest number $R_n$ such that $\pi  x-\frac{\pi  x}{2}\geq n$ for all $x\geq R_n$ :

```wl
In[1]:= list = Table[PrimePi[n] - PrimePi[n / 2], {n, 10 ^ 4}];

In[2]:= ramanujanPrime = 1 + Last[Position[list, #]][[1]]& /@ Range[0, 50];

In[3]:= ramanujanPrimePi[n_] := Count[ramanujanPrime, _ ? (# ≤ n&)]
```

Plot the sequence of Ramanujan primes:

```wl
In[4]:= Plot[ramanujanPrimePi[n], {n, 0, 100}]

Out[4]= [image]
```

Compare the count of Ramanujan primes to ``PrimePi`` :

```wl
In[5]:= Plot[{ramanujanPrimePi[n], PrimePi[n]}, {n, 0, 100}]

Out[5]= [image]
```

---

Calculate the primorial up to the $n$$$^{\text{th}}$$ prime, i.e. a function that multiplies successive primes, similar to the factorial:

```wl
In[1]:=
primorial[0] := 1
primorial[1] := 2
primorial[n_] := Times@@Prime@Range[n];

In[2]:= primorial[5]

Out[2]= 2310
```

Compare the primorial to the factorial up to $n$ :

```wl
In[3]:= DiscretePlot[{Log[n!], Log[Times@@Prime[Range[PrimePi[n]]]]}, {n, 1, 50}]

Out[3]= [image]
```

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

```wl
In[4]:= ListLinePlot[If[True, Differences, Identity][Table[Log[(n!/Times@@Prime[Range[PrimePi[n]]])], {n, 1, 100, 1}]], Filling -> Axis]

Out[4]= [image]
```

Plot the Chebyshev theta function:

```wl
In[5]:= chebyshevTheta[n_] := Log[primorial[PrimePi[n]]];

In[6]:= Plot[chebyshevTheta[n], {n, 1, 100}]

Out[6]= [image]

In[7]:= DiscretePlot[{chebyshevTheta[n], PrimePi[n]}, {n, 1, 100}]

Out[7]= [image]
```

---

Calculate the prime powers up to $n$ :

```wl
In[1]:= primePowers[n_] := Union@@Table[Prime[Range[PrimePi[n ^ (1 / x)]]] ^ x, {x, Log2[n]}]

In[2]:= primePowers[10]

Out[2]= {2, 3, 4, 5, 7, 8, 9}

In[3]:= PrimePowerQ[%]

Out[3]= {True, True, True, True, True, True, True}
```

Count all the prime powers up to $n$ :

```wl
In[4]:= primePowerPi[n_] := PrimePi[n] + Sum[Floor@Log[Prime[k], n] - 1, {k, PrimePi[Sqrt[n]//Floor]}]

In[5]:= primePowerPi[10]

Out[5]= 7
```

Graph the count of prime powers:

```wl
In[6]:= DiscretePlot[primePowerPi[n], {n, 1, 100}]

Out[6]= [image]
```

Compare the count of prime powers to ``PrimePi`` :

```wl
In[7]:= DiscretePlot[{primePowerPi[n], PrimePi[n]}, {n, 1, 100}]

Out[7]= [image]
```

---

Visualize the second Hardy–Littlewood conjecture, which states that $\pi  (x+y)\leq \pi  (x)+\pi  (y)$ for $x,y\geq 2$ :

```wl
In[1]:= ArrayPlot[((Outer[Plus, #, #]&)[PrimePi[Range[2, 20]]] - Outer[PrimePi[+##1]&, #, #]&)[Range[2, 20]], Rule[...]]

Out[1]= [image]
```

---

Plot Brocard's conjecture, which states that if $p_n$ and $p_{n+1}$ are consecutive primes greater than 2, then between $p_n^2$ and $p_{n+1}^2$ there are at least four prime numbers:

```wl
In[1]:= ListStepPlot[-Subtract@@@Partition[PrimePi[Prime[Range[100]] ^ 2], 2, 1], Rule[...]]

Out[1]= [image]
```

---

Find Goldbach partitions, i.e. pairs of primes ($p$, $q$) such that $2n=p+q$ :

```wl
In[1]:= goldbachPartitions[n_] := IntegerPartitions[2n, {2}, Prime[Range[PrimePi[2n]]]]

In[2]:= goldbachPartitions[50]

Out[2]= {{97, 3}, {89, 11}, {83, 17}, {71, 29}, {59, 41}, {53, 47}}
```

Graph Goldbach's conjecture/comet:

```wl
In[3]:= ListPlot[Transpose[{Range[4, 1000, 2], Length /@ Table[IntegerPartitions[i, 2, Table[Prime[n], {n, PrimePi[i]}]], {i, 4, 1000, 2}]}], Rule[...]]

Out[3]= [image]
```

---

The only 8 solutions of $\pi (x)=\phi (x)$ :

```wl
In[1]:= Cases[Range[100], n_ /; PrimePi[n] == EulerPhi[n]]

Out[1]= {2, 3, 4, 8, 10, 14, 20, 90}

In[2]:= DiscretePlot[{PrimePi[n], EulerPhi[n]}, {n, 1, 22}, Rule[...]]

Out[2]= [image]
```

### Properties & Relations (5)

The largest domain of definitions of ``PrimePi``:

```wl
In[1]:= FunctionDomain[PrimePi[x], x, Complexes]

Out[1]= x∈ℝ
```

---

``PrimePi`` is asymptotically equivalent to $\frac{x}{\log (x)}$ as $x\to \infty$ :

```wl
In[1]:= AsymptoticEquivalent[PrimePi[x], x / Log[x], x -> Infinity]

Out[1]= True
```

And to ``LogIntegral`` :

```wl
In[2]:= AsymptoticEquivalent[PrimePi[x], LogIntegral[x], x -> Infinity]

Out[2]= True
```

---

``PrimePi`` is the inverse of ``Prime`` :

```wl
In[1]:= PrimePi[Prime[100]]

Out[1]= 100
```

---

Use ``PrimeQ`` to count prime numbers:

```wl
In[1]:= Count[Table[PrimeQ[n], {n, 1, 1000}], True]

Out[1]= 168

In[2]:= PrimePi[1000]

Out[2]= 168
```

---

Mathematical function entity:

```wl
In[1]:= Entity["MathematicalFunction", "PrimePi"]

Out[1]= Entity["MathematicalFunction", "PrimePi"]
```

An integral representation of ``PrimePi`` :

```wl
In[2]:= Entity["MathematicalFunction", "PrimePi"]["IntegralRepresentations"]

Out[2]= {Function[{\[FormalN]}, Inactivate[ConditionalExpression[PrimePi[\[FormalN]] == \[FormalN] - 1 - (Subsuperscript[∫, 0, 2 π](Underoverscript[∑, \[FormalM] = 1, \[FormalN]]Cos[\[FormalT] Underoverscript[∏, \[FormalK] = 1, \[FormalM] - 1]Underoverscript[∏, \[FormalJ] = 1, \[FormalM] - 1](\[FormalJ] \[FormalK] - \[FormalM])])\[DifferentialD]\[FormalT]/2 π), \[FormalN]∈ℤ && \[FormalN] > 0]]]}
```

### Possible Issues (1)

Evaluation time increases exponentially:

```wl
In[1]:= ListLinePlot[Table[First[AbsoluteTiming[PrimePi[10 ^ n]]], {n, 14, 19, .5}], ...]

Out[1]= [image]
```

### Neat Examples (3)

Ulam spiral colored based on the difference in ``PrimePi`` values:

```wl
In[1]:=
ulam[n_] := Partition[Permute[Range[n ^ 2], Accumulate[Take[Flatten[{{n ^ 2 + 1} / 2, Table
	[(-1) ^ j i, {j, n}, {i, {-1, n}}, {j}]}], n ^ 2]]], n]

In[2]:= ArrayPlot[PrimePi[ulam[101] + 10] - PrimePi[ulam[101]], Rule[...]]

Out[2]= [image]
```

---

Generate a path based on the ``PrimePi`` function:

```wl
In[1]:= Graphics[Line[AnglePath[Table[PrimePi[n], {n, 1, 1000}]], Rule[...]]]

Out[1]= [image]
```

---

Construct polyhedra using directed graphs generated by primes less than $p$ :

```wl
In[1]:=
vertexcoords[p_] := 
	GraphEmbedding[Graph3D[Flatten[Table[i -> Mod[i * q, p], {i, 1, p - 1}, {q, Prime[Range[PrimePi[p] - 1]]}]]]]

In[2]:= Table[ConvexHullMesh[vertexcoords[p], Rule[...]], {p, Prime[Range[4, 7]]}]

Out[2]= {[image], [image], [image], [image]}
```

## See Also

* [`Prime`](https://reference.wolfram.com/language/ref/Prime.en.md)
* [`NextPrime`](https://reference.wolfram.com/language/ref/NextPrime.en.md)
* [`RiemannR`](https://reference.wolfram.com/language/ref/RiemannR.en.md)
* [`LogIntegral`](https://reference.wolfram.com/language/ref/LogIntegral.en.md)
* [`Zeta`](https://reference.wolfram.com/language/ref/Zeta.en.md)
* [`ZetaZero`](https://reference.wolfram.com/language/ref/ZetaZero.en.md)
* [`EulerPhi`](https://reference.wolfram.com/language/ref/EulerPhi.en.md)

## Tech Notes

* [Integer and Number Theoretic Functions](https://reference.wolfram.com/language/tutorial/MathematicalFunctions.en.md#20170)
* [Implementation Notes: Numerical and Related Functions](https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.en.md#12788)

## Related Guides

* [Prime Numbers](https://reference.wolfram.com/language/guide/PrimeNumbers.en.md)
* [Analytic Number Theory](https://reference.wolfram.com/language/guide/AnalyticNumberTheory.en.md)
* [Multiplicative Number Theory](https://reference.wolfram.com/language/guide/MultiplicativeNumberTheory.en.md)
* [Mathematical Functions](https://reference.wolfram.com/language/guide/MathematicalFunctions.en.md)
* [Number Theory](https://reference.wolfram.com/language/guide/NumberTheory.en.md)
* [Number Theoretic Functions](https://reference.wolfram.com/language/guide/NumberTheoreticFunctions.en.md)

## Related Links

* [MathWorld](http://mathworld.wolfram.com/PrimeCountingFunction.html)
* [An Elementary Introduction to the Wolfram Language: More about Numbers](https://www.wolfram.com/language/elementary-introduction/23-more-about-numbers.html)
* [NKS\|Online](http://www.wolframscience.com/nks/search/?q=PrimePi)
* [A New Kind of Science](http://www.wolframscience.com/nks/)

## History

* Introduced in 1991 (2.0) \| [Updated in 2020 (12.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn121.en.md) ▪ [2021 (12.3)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn123.en.md)