Prime Number Generator
Generate primes with the Sieve of Eratosthenes.
Primes are found with the Sieve of Eratosthenes — it marks the multiples of each prime, leaving the primes behind.
Primes found
25
Largest in this set: 97
How to use Prime Number Generator
What this calculator does
This tool generates prime numbers. You can list every prime up to a limit you choose, or ask for the first N primes regardless of how high the last one reaches. The generator returns the total count of primes found and the full list in a scrollable container, with the largest value in the set highlighted. It uses the Sieve of Eratosthenes, the standard fast method for producing primes in bulk. The count can be copied with one click, the whole list can be copied as a comma-separated string, and everything recalculates live as you adjust the input.
Why you might need it
A ready list of primes is useful across mathematics and computing. Students verifying homework or exploring number patterns need primes on demand. Programmers use prime lists to size hash tables, seed test data, or implement algorithms that depend on prime gaps. Puzzle setters and educators reference primes when designing problems. Anyone studying the distribution of primes — how they thin out as numbers grow — benefits from seeing hundreds of them at once. Generating primes by hand is tedious and mistakes creep in quickly, so an instant, accurate generator is a genuine time-saver.
How to use it
- Choose a mode. “All primes up to a limit” asks for a ceiling; “First N primes” asks for a count.
- Enter your number. The limit is capped at one million; the count is capped at fifty thousand. These caps keep the tool fast.
- Read the count of primes found in the headline card, along with the largest prime in the set.
- Scroll the list to browse every prime, and use the copy buttons to copy the count or the entire comma-separated list.
How it’s calculated
The Sieve of Eratosthenes works by elimination rather than by testing each number. Imagine the whole numbers from 2 up to your limit written in a row. The first uncrossed number, 2, is prime, so every multiple of 2 — 4, 6, 8 and so on — is crossed out. The next uncrossed number, 3, is prime, so its multiples are crossed out, and so the process continues. A key optimisation is to start crossing out from the prime’s square: any smaller multiple, such as 2 × 3 for the prime 3, has already been crossed by a smaller prime. Whatever remains uncrossed is exactly the set of primes. For the “first N primes” mode the tool estimates a high enough ceiling using the prime number theorem — the nth prime is close to n × (ln n + ln ln n) — runs the sieve, and grows the ceiling if the estimate fell slightly short.
Common pitfalls
A common error is forgetting that 1 is not prime; the smallest prime is 2. Another is expecting primes below 2 — there are none, so a limit under 2 returns an empty list. In “first N primes” mode the last prime can be much larger than N itself, since primes thin out as numbers grow: the 1000th prime is 7919. Finally, remember that the limit and the count are different things — a limit of 100 yields 25 primes, not 100.
Tips
To see how primes become sparser, generate the primes up to 100, then up to 1000, and compare how the count grows much more slowly than the limit. For algorithm work, the comma-separated copy makes it easy to paste a prime list straight into code or a spreadsheet. Because the sieve runs locally and quickly, you can experiment freely with different ranges, and nothing you enter ever leaves your browser.
Frequently asked questions
What is the Sieve of Eratosthenes?
What is the difference between the two modes?
Why are the limits capped?
Is 2 really a prime number?
Does this send my input to a server?
Related tools
Prime Number Checker
Check whether a number is prime.
Fibonacci Generator
Generate the Fibonacci sequence up to any term.
Factorial Calculator
Calculate factorials, even for very large numbers.
GCD & LCM Calculator
Find the GCD and LCM of multiple numbers.
Permutation & Combination Calculator
Calculate permutations (nPr) and combinations (nCr).
Roman Numeral Converter
Convert between numbers and Roman numerals.