Prime number generator
List the first N primes (up to 200), or every prime in a range up to 1,000,000. Runs in your browser.
Output · 24 primes
ReadyA prime has exactly two divisors: 1 and itself. The “in range” mode uses a sieve of Eratosthenes; “first N” tests candidates one by one. 2 is the only even prime.
- Modes
- First N · range
- Method
- Sieve
Related tools
This prime number generator lists primes two ways: the first N primes, up to 200 of them, or every prime between two numbers, with the upper bound capped at 1,000,000. Range mode uses a sieve of Eratosthenes. First N tests each candidate in turn. Copy the results as a comma-separated list or as a CSV with an index column.
How to use the prime number generator
- Pick a mode: First N or In range.
- For First N, drag the Count slider (1 to 200). For In range, type a minimum and a maximum. Both ends count.
- The list updates as you type. The grid shows up to 200 primes.
- Copy as list copies every prime, separated by commas. Copy CSV adds an index column.
How the sieve of Eratosthenes works
Write out the numbers from 2 to your upper bound. 2 is prime, so cross out every multiple of 2. The next number still standing, 3, is prime too, so cross out its multiples. Keep going. Once you pass the square root of the upper bound, whatever is left uncrossed is prime. It's more than 2,000 years old and still a quick way to get every prime below a fixed limit, which is why range mode uses it.
Frequently asked questions
What is a prime number?
A whole number greater than 1 whose only positive divisors are 1 and itself. The first few are 2, 3, 5, 7, 11, and 13.
Is 1 a prime number?
No. Primes have to be greater than 1. The number 1 is called a unit.
What is the sieve of Eratosthenes?
An ancient method for finding every prime up to a limit by crossing out the multiples of each prime, starting from 2.
How many primes can this generator list?
First N stops at 200. In range mode the upper bound is capped at 1,000,000, a span that holds 78,498 primes. The grid shows 200 of them, and Copy as list copies the rest too.
Is 2 the only even prime?
Yes. Every even number above 2 is divisible by 2, so it can't be prime.
Built and maintained by Bipul Kumar. Found a wrong number or a broken result? Tell me and I'll fix it.