Prime Number Generator and Sieve Calculator
Generate prime numbers
Use non-negative whole numbers with start ≤ end. Commas and spaces are accepted.
Results
Choose a range and select Generate primes.
Interactive sieve chart
The chart shows up to the first 300 integers in your selected range. Green cells are prime; grey cells are composite; 0 and 1 are neither.
Generate a range to update the chart.
Advertisement
How the Sieve of Eratosthenes works
- Write the integers from 2 through the ending value.
- Keep 2 and mark every larger multiple of 2 as composite.
- Move to the next unmarked number, 3, and mark its larger multiples.
- Repeat for unmarked numbers through √n. Every remaining unmarked integer is prime.
Why marking begins at p2
For a current prime p, smaller multiples 2p, 3p, …, (p − 1)p have already been marked by smaller prime factors. The first new multiple is therefore p2.
The classic sieve uses O(n) memory and O(n log log n) time.
Prime number examples
| Range | Prime numbers | Count |
|---|---|---|
| 0–10 | 2, 3, 5, 7 | 4 |
| 10–30 | 11, 13, 17, 19, 23, 29 | 6 |
| 90–110 | 97, 101, 103, 107, 109 | 5 |
| 1–100 | The first 25 primes, from 2 through 97 | 25 |
The endpoints are inclusive: if either endpoint is prime, it appears in the list. Prime density is calculated as the number of primes divided by the number of integers in the selected range.
Prime generator FAQ
What is the Sieve of Eratosthenes?
It is an algorithm that lists primes by marking multiples of each prime, beginning with 2. Unmarked integers greater than 1 are prime.
Why does the sieve stop crossing out at the square root?
Every composite number has a factor no greater than its square root. Once primes through √n have been processed, every composite has already been marked.
Are 0 and 1 prime numbers?
No. A prime is an integer greater than 1 with exactly two positive divisors: 1 and itself.
Are both endpoints included?
Yes. Every integer from the start through the end is checked, including both endpoints.
How large can the range be?
The ending value can be at most 10,000,000. The cap keeps memory use and calculation time reasonable, especially on phones. Long lists are shortened on screen, but Copy and Download include every generated prime.
Does the tool upload or track my range?
No. The sieve runs locally in a Web Worker in your browser. Your entered range is not uploaded or stored by the calculator.
