GenerateRandomSearch

Prime Gap Generator

Primes thin out as numbers grow, but not evenly — the gaps jump about, and where they are largest is genuinely unpredictable. This lists consecutive primes from wherever you start, with the gap after each, and highlights twin pairs: primes two apart, which are conjectured to go on forever without anyone having proved it. Every gap is verified by checking that nothing inside it is prime.

What this generator does

Finds primes one after another from your starting point by trial division, records the distance to the next, and identifies the largest gap and every twin pair in the run.

How to use this tool

  1. Choose where to start and how many primes to list.
  2. Read the gap after each prime.
  3. Look for twin pairs, where the gap is exactly two.
  4. Compare the largest gap against what you would expect at that size.

Understanding the controls

Start from
Any number up to 100,000. The first prime at or above it begins the list.
How many primes
Between 5 and 40. Forty rows is about as much as reads usefully at once.
Seed
Not used here — the primes above a given number are what they are, so this tool has nothing random in it.

Common use cases

  • Showing that prime gaps grow on average but not steadily
  • Finding twin primes in a chosen range
  • Data for a distribution-of-primes exercise
  • Test values for anything that consumes consecutive primes
  • Illustrating why every gap above 2 is even

How this generator works

Primality is trial division up to the square root, which is exact and fast at these sizes. The check re-tests every listed number for primality and, for each gap, confirms that every single number strictly inside it is composite — which is what makes them consecutive.

Randomness and fairness

Nothing here is random. The primes above a starting point are fixed, so the same input always gives the same output whether or not a seed is set.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Starting points stop at 100,000, above which trial division starts to feel slow in a browser.
  • Only consecutive primes are listed; the count of primes below a bound is a different question.
  • Gaps are shown as numbers rather than plotted.
  • Nothing here proves anything about twin primes in general — that conjecture is still open.
  • Lists are not stored between visits.

Privacy and your data

Primes are found in your browser by trial division. Your starting point is never transmitted or stored.