CalcWorldHub
Free online calculator · no signup

Prime counting calculator

Count the prime numbers at or below an integer upper limit x.

Prime counting calculator — Upper limit x (0–5,000,000) and calculation method
Prime counting calculator: inputs and calculation method.

How to use this calculator

Count the prime numbers at or below an integer upper limit x.

  1. Enter Upper limit x (0–5,000,000). Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

How Prime counting calculator works

Count the prime numbers at or below an integer upper limit x.

Inputs and units

  • Upper limit x (0–5,000,000): x is the inclusive upper limit; the count includes 2 when x≥2.

Formula and method

π(x)=#{p prime: p≤x}. For noninteger positive x, the count is the same as at floor(x).

Worked example

At x=10, the primes are 2, 3, 5, and 7, so π(10)=4.

Interpreting the result

The output counts primes, not prime factors with multiplicity. For x=1000, π(x)=168.

Assumptions and limits

The supported upper bound is 5,000,000. Values below 2 have count zero; the algorithm uses integer cutoffs.

Sources and method

Frequently asked questions

Does 1 count as prime?

No. The first prime is 2.

Does x count when x itself is prime?

Yes. The upper limit is inclusive.

How do I use the Prime counting calculator?

Enter Upper limit x (0–5,000,000). Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Prime counting?

At x=10, the primes are 2, 3, 5, and 7, so π(10)=4.

What does the Prime counting calculator calculate?

Count the prime numbers at or below an integer upper limit x.

Related calculators