Sieve of Eratosthenes
Generate all prime numbers up to a limit using the Sieve of Eratosthenes, the classic efficient algorithm, with the prime count.
Last reviewed by the Radiatus Cloud team
Generate all prime numbers up to a limit with the Sieve of Eratosthenes.
Need this done properly for your business?
Radiatus delivers secure cloud, DevOps & compliance engineering.
Generate primes with the sieve
The Sieve of Eratosthenes is a classic and efficient algorithm for finding all prime numbers up to a given limit. It works by listing the numbers and repeatedly crossing out the multiples of each prime, starting from two; whatever remains uncrossed is prime. This tool runs the sieve and lists every prime up to your limit, along with how many there are and the largest one. Up to one hundred, there are twenty-five primes, the largest being ninety-seven.
The algorithm is named after the ancient Greek scholar Eratosthenes, who also famously measured the circumference of the Earth.
Why the sieve is efficient
Rather than testing each number individually for primality, the sieve eliminates composites in bulk by marking off multiples, which makes it far faster for generating all primes in a range. A key optimisation, used here, is to start crossing out from the square of each prime, since smaller multiples will already have been marked. Prime numbers underpin cryptography, hashing and number theory, so generating them efficiently is widely useful.
For very large limits the list of primes becomes long, so the tool shows a capped preview while still reporting the full count. All calculation happens locally in your browser.
Related tools
- Data Collection Analysis — Analyze app description to infer data collection.
- Dark Pattern Detector — Scan UX text for manipulative patterns.
- AI Risk Disclosure — Generate disclosure text for AI features.
- Maturity Radar — Generate a radar chart of security maturity.
Frequently Asked Questions
How does the sieve work?
It lists numbers and crosses out the multiples of each prime in turn, starting at two. The numbers left uncrossed are the primes.
Why start crossing out at the square of a prime?
Smaller multiples of a prime are already marked by smaller primes, so starting at the square avoids redundant work and speeds up the sieve.
How many primes are there below 100?
Twenty-five, ranging from two up to ninety-seven, which the tool lists in full along with the total count.
Why is it faster than testing each number?
It eliminates composites in bulk by marking multiples, rather than individually testing every number for primality, which is much slower for a range.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Enter an upper limit to list all primes up to it.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.