Loading…

Prime Numbers in a Range

Math Algebra • Numbers

View all topics

Generate all prime numbers in an inclusive range \([a,b]\), count them, and visualize their distribution. A prime number is an integer greater than \(1\) with exactly two positive divisors: \(1\) and itself. This calculator uses the Sieve of Eratosthenes: \[ \begin{aligned} \text{mark multiples of each prime }p\le \sqrt{b}. \end{aligned} \]

Range input

The range is inclusive. The calculator accepts \(a=1\), but \(1\) is not prime. For a fast browser-based display, use \(1\le a\le b\le 200000\).

Quick examples

Ready
Enter a range, then click “Calculate”.

Rate this calculator

0.0 /5 (0 ratings)
Be the first to rate.
Your rating
You can update your rating any time.

Frequently Asked Questions

What is a prime number?

A prime number is an integer greater than 1 with exactly two positive divisors: 1 and itself.

Is 1 a prime number?

No. The number 1 is not prime because it has only one positive divisor.

What are the primes from 1 to 100?

They are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, and 97.

How many primes are there from 1 to 100?

There are 25 primes from 1 to 100.

How does the Sieve of Eratosthenes work?

The sieve marks multiples of each prime starting from 2. The numbers that remain unmarked are prime.

Why does the sieve only need to use primes up to sqrt(b)?

Any composite number up to b has at least one factor less than or equal to sqrt(b), so marking with base primes up to sqrt(b) is enough.

Why does marking begin at p squared?

Smaller multiples of p have already been marked by smaller primes, so p squared is the first new multiple that must be marked.

What is prime density?

Prime density in a range is the number of primes divided by the number of integers in that range.

What does pi(b) mean?

The prime-counting function pi(b) is the number of primes less than or equal to b.

Can I export the prime list?

Yes. The calculator can copy the prime list or download it as a text or CSV file.