About the Prime Number Generator
A prime has exactly two divisors, itself and one, which is why 1 is not prime and 2 is the only even prime. This generator finds them with a sieve of Eratosthenes: it writes out every number up to the limit, then repeatedly crosses off the multiples of the smallest number still standing. Whatever survives is prime. The sieve is fast enough that a range reaching a few million completes before the page has finished repainting.
Three modes cover the usual requests. All in a range lists the primes between your two bounds, which is what a homework sheet or a test fixture usually needs. First N primes counts from 2 upward until it has as many as you asked for, sizing its own sieve using the standard estimate for the nth prime. Random from a range draws a sample without repeats, which is handy for generating unpredictable test data that still has the property you care about.
The layout options matter more than they look. One per line pastes straight into a spreadsheet column, comma separated drops into an array literal, and ten per row gives the aligned block a printed worksheet wants. The statistics block adds the count, the smallest and largest values, the sum, how many twin prime pairs the list contains, and the largest gap between consecutive primes, which is the fastest way to spot the long empty stretches primes fall into. The upper bound is capped at five million so a stray keystroke cannot freeze the tab. For unpredictable integers with no divisibility rules attached, use the Random Number Generator.
How to use
- Choose a Mode: a full range, the first N primes, or a random sample.
- Set From and To for range modes, or How many for the other two.
- Pick a layout that matches where the numbers are going next.
- Read the statistics block for the count, sum, twin pairs and largest gap.
Common questions
- Is 1 a prime number?
- No. A prime needs exactly two distinct divisors and 1 has only one, so the list always starts at 2 even when you set the lower bound to 1.
- How large a range can I ask for?
- The upper bound is capped at five million. Beyond that a browser sieve starts allocating enough memory to make the tab unresponsive.
- What are twin primes?
- A pair of primes two apart, such as 11 and 13. The statistics block counts how many such pairs appear inside the list you generated.
- Are the random primes different every time?
- Yes. Each run draws a fresh sample without repeats, so pressing Generate again gives a different set from the same range.