Math Tools

Home
Prime CheckerFibonacci GeneratorBasic CalculatorBase ConverterGCD & LCMBinary Converter

Prime Number Generator

Generate lists of prime numbers, find primes in any range, or check if a number is prime

Your files never leave your browser
Primes

Generate prime numbers in any range, grab the first N primes, or check whether a specific number is prime — with full factorization, twin prime flags, and Mersenne prime markers included. Results show up in milliseconds for most inputs, and you can copy or download them as .txt or .csv.

And everything runs in your browser. Nothing gets uploaded.

How It Works

Pick Mode & Range
→
Sieve of Eratosthenes
→
Primes + Stats

The tool uses the Sieve of Eratosthenes for range-based generation — it marks off multiples of each prime starting from 2, leaving only primes standing. For single-number checks, it runs trial division up to the square root. Large ranges get processed in chunks so your browser stays responsive.

Examples

Quick homework check

You need the first 10 primes for a math assignment. Done in one click.

INPUT
First 10 primes
OUTPUT
2, 3, 5, 7, 11, 13, 17, 19, 23, 29

Finding primes for a hash table size

You’re building a hash table and want a prime bucket count near 1,000. Generating primes from 990 to 1,010 gives you good candidates.

INPUT
Range: 990 – 1010
OUTPUT
991, 997, 1009 (3 primes found)

Is 7,919 actually prime?

A friend claims 7,919 is the 1,000th prime. You can verify both the primality and the position in under a second. The tool checks divisibility up to √7,919 ≈ 89 and confirms it has no factors other than 1 and itself.

INPUT
Check: 7919
OUTPUT
7,919 is PRIME It is the 1,000th prime Not a twin prime Not a Mersenne prime

Who Uses This

👨‍💻 Developers

Picking prime-sized hash tables, testing modular arithmetic functions, or generating test data for cryptography code.

🎓 Students

Verifying homework answers, exploring prime distribution patterns, or studying the Sieve of Eratosthenes visually.

📊 Data Scientists

Generating prime sequences for sampling algorithms or analyzing prime gap distributions in number theory research.

🧩 Puzzle Enthusiasts

Solving Project Euler problems, math competitions, or just satisfying curiosity about twin primes and Mersenne primes.

Common Mistakes

Thinking 1 is prime

It isn’t. By convention (and for good mathematical reasons), 1 is excluded from the primes. The smallest prime is 2. If your range starts at 1, don’t expect it in the output.

Setting a range too wide and wondering why it’s slow

Generating all primes up to 10 million works, but your browser needs a moment. If you only care about primes near a specific number, narrow the range instead of sieving from 2.

Confusing “first N primes” with “primes up to N”

Asking for the first 100 primes gives you 2 through 541. Asking for primes up to 100 gives you 2 through 97 — that’s only 25 primes. Pick the right mode for what you actually need.

Technical Details

Frequently Asked Questions

What is a prime number?

A prime number is any whole number greater than 1 that can only be divided evenly by 1 and itself. So 7 is prime because nothing divides into it cleanly besides 1 and 7. The number 6 isn’t, because 2 × 3 = 6.

Why is 2 the only even prime?

Every even number is divisible by 2. That means any even number larger than 2 already has at least three divisors: 1, 2, and itself. So 2 is the odd one out — the only even number that qualifies as prime.

What are twin primes?

Twin primes are pairs that sit exactly 2 apart — like (11, 13) or (29, 31). Whether there are infinitely many twin pairs is still an open question in math. This tool flags them in blue so they’re easy to spot in your results.

What is a Mersenne prime?

A Mersenne prime has the form 2^n − 1, where n itself is prime. The ones you’ll see in this tool’s range are 3, 7, 31, 127, 8191, 131071, and 524287. They show up with a gold marker. Finding new Mersenne primes is a big deal — GIMPS, a distributed computing project, has been hunting them since 1996.

How many primes are there below one million?

There are exactly 78,498 primes under 1,000,000. That’s roughly 7.8% of all numbers in that range. As numbers get bigger, primes thin out — but they never stop appearing entirely. The prime number theorem says the density drops off like 1/ln(n).

Share: