ToolJutsu
All tools
Calculator Tools

Prime Number Generator

Generate primes with the Sieve of Eratosthenes.

Mode

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

Prime numbers
2357111317192329313741434753596167717379838997
Processed on your device. We never see your files.

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

  1. Choose a mode. “All primes up to a limit” asks for a ceiling; “First N primes” asks for a count.
  2. Enter your number. The limit is capped at one million; the count is capped at fifty thousand. These caps keep the tool fast.
  3. Read the count of primes found in the headline card, along with the largest prime in the set.
  4. 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?
It is a classic algorithm, more than two thousand years old, for finding every prime up to a limit. You list the whole numbers from 2 upward, then repeatedly take the next un-crossed number as a prime and cross out all of its multiples. Whatever survives uncrossed is prime. It is far faster than testing each number individually.
What is the difference between the two modes?
'All primes up to a limit' returns every prime less than or equal to the ceiling you set. 'First N primes' returns a fixed quantity of primes regardless of how large the last one is. Choose the first when you care about a value range and the second when you need a specific count.
Why are the limits capped?
The ceiling for 'up to a limit' mode is one million and the count for 'first N primes' mode is fifty thousand. These caps keep the sieve fast and the scrollable list smooth on phones. If you exceed them the tool shows a short message rather than freezing the page.
Is 2 really a prime number?
Yes. 2 is the smallest prime and the only even one — its only divisors are 1 and 2. Every other even number is divisible by 2 as well, which makes it composite. After 2, all primes are odd.
Does this send my input to a server?
No. The sieve runs entirely in your browser using JavaScript. Your chosen limit or count is never uploaded or stored, and the generator keeps working even if you go offline.

Related tools