Random Prime Number Generator
Random primes in any range, plus the full list of primes under 100.
Generated numbers
Your numbers will appear here. Press Generate to start.
Generate random prime numbers — values divisible only by one and themselves — from any range up to two million. Primes are what you reach for when you need numbers with no shared factors: hash table sizes, modular arithmetic, teaching examples and puzzle construction all depend on that property. All 25 primes below 100 are listed on this page.
Every match from 1 to 100
There are 25 of them, listed in full below. The generator above draws from exactly this set, so every result you get is one of these — and each is equally likely.
- 2
- 3
- 5
- 7
- 11
- 13
- 17
- 19
- 23
- 29
- 31
- 37
- 41
- 43
- 47
- 53
- 59
- 61
- 67
- 71
- 73
- 79
- 83
- 89
- 97
Why use this tool?
Genuinely prime
Candidates come from a sieve rather than a probabilistic test, so every result is certainly prime — not probably prime.
Uniform across the range
Primes thin out as numbers grow, which makes naive random-then-test approaches biased toward the dense low end. Drawing from the enumerated set gives every prime in your range an equal chance.
The prime list included
All 25 primes below 100 are on this page as plain text, which is what most people searching for a prime generator actually want.
Up to two million
Any range within 2,000,000 is supported, which covers hash sizes, teaching examples and puzzle work.
How this random prime number generator works
When you generate, the tool runs a Sieve of Eratosthenes over your range: it lists the numbers, repeatedly crosses out the multiples of each survivor, and what remains is exactly the primes. It is an algorithm from around 240 BC and it is still the right answer at this scale — sieving to a million takes a few milliseconds.
The random draw then picks positions in that list rather than testing candidate numbers for primality. This matters more than it sounds. Primes get sparser as numbers grow — there are 25 below 100 but only 8 between 900 and 1000 — so drawing a random number and retrying until it happens to be prime lands disproportionately in the crowded low end. Drawing from the list directly gives every prime an equal chance.
The two million ceiling is deliberate. Beyond it, sieving in a browser tab starts to cost noticeable memory, and the honest answer is to refuse rather than to freeze the page. Cryptographic primes, which are hundreds of digits long, are a different problem entirely and need a different tool.
How to use it
Step 1: Set a range
Enter the minimum and maximum. The maximum must be two million or less.
Step 2: Choose how many
Pick a quantity and decide whether the same prime may appear twice.
Step 3: Generate
Press Generate, then copy a value or export the batch.
Example usage
- Sizing a hash table
- A prime table size spreads keys more evenly when the hash function has weak low bits — a long-standing reason to pick a prime rather than a round number.
- Building maths problems
- A batch of random primes as the basis for factorisation exercises, with the list on this page as the answer key.
- Modular arithmetic examples
- A prime modulus makes every non-zero value invertible, which is what makes worked examples come out cleanly.
Frequently asked questions
How many prime numbers are there between 1 and 100?
Twenty-five: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97. The full list is on this page.
Is 1 a prime number?
No. A prime has exactly two distinct divisors, one and itself, and 1 has only one divisor. Excluding it is what lets every number have a single unique prime factorisation, so the convention earns its keep.
Is 2 really prime?
Yes — it is the only even prime. Every other even number has 2 as a divisor, which disqualifies it. That makes 2 the exception people most often forget.
Can I generate primes for cryptography?
No, and you should not try. Cryptographic primes are hundreds of digits long and must be generated inside the key generation routine of a vetted library, alongside the other checks that make a key safe. This tool is for ranges up to two million and is aimed at teaching, puzzles and general use.
Why is the maximum two million?
Because the sieve has to enumerate the range, and beyond that point the memory cost in a browser tab becomes noticeable. Refusing clearly is better than freezing the page.
Related tools
Fibonacci Number Generator
Random Fibonacci numbers, with the sequence listed in full.
Random Even Number Generator
Random even numbers in any range, plus the full list from 1 to 100.
Random Number Generator
Set any minimum and maximum and draw as many numbers as you need.
Browse every tool in Random Number Generators & Number Tools.