Prime Gap Sequence Calculator

Generate consecutive primes, measure their gaps, classify notable pairs, inspect records, and export a complete mathematical analysis.

Optional. Index 1 starts with prime 2.

Results

Primes—
Gaps—
Maximum gap—
Minimum gap—
Average gap—
Median gap—

Prime sequence

No calculation yet.

Prime gap sequence

No calculation yet.
Index Current prime Next prime Gap Gap type Record gap Formula
Run a calculation to populate the table.

Gap frequency

GapFrequencyShare
No data.

Sequence summary

No data.

Formula used

The prime gap after the nth prime is gn = pn+1 − pn. The calculator first generates ordered primes. It then subtracts each prime from the next prime.

For example, 11, 13, 17, and 19 produce gaps 2, 4, and 2. A gap of 2 identifies a twin-prime pair. Gap 4 identifies a cousin-prime pair. Gap 6 identifies a sexy-prime pair.

How to use this calculator

Select a range, fixed prime count, or surrounding-gap mode. Enter valid whole numbers. Apply optional exact-gap or minimum-gap filters. You can also show only record gaps or twin-prime gaps.

Press Calculate to generate the prime list and gap table. Click any sortable table heading to reorder results. Export the results as CSV or PDF when finished.

Prime gap sequence guide

Prime numbers are integers greater than one with exactly two positive divisors. Consecutive primes do not appear at fixed distances. Their changing distances form a prime gap sequence. This makes prime gaps useful for exploring number patterns and computational number theory.

Reading the sequence

The calculator creates an ordered prime list first. Each displayed gap equals the next prime minus the current prime. The pair 13 and 17 has gap four. The pair 17 and 19 has gap two. Except for the first gap between two and three, gaps between consecutive primes are even. Every prime greater than two is odd. Subtracting two odd numbers produces an even result.

Special prime pairs

A gap of two produces twin primes. Examples include 11 and 13. A gap of four produces cousin primes. A gap of six produces sexy primes. The calculator labels these common cases automatically. Larger gaps can also be studied through frequency counts and record-gap markers.

Using statistics

The maximum gap shows the widest spacing inside the selected data. The minimum shows the smallest observed spacing. Average and median values summarize typical gap sizes. Frequency counts reveal which gaps appear most often. Record gaps identify new largest gaps as the prime sequence grows.

Practical exploration

Try increasing the ending value and compare the new results. You can search for exact gaps, impose minimum thresholds, or inspect only records. These options make the calculator useful for lessons, demonstrations, sequence study, and quick experiments. CSV export supports further analysis. PDF export creates a portable report for printing or sharing.

Example table

Prime pairCalculationGapClassification
2, 33 − 21Initial odd gap
3, 55 − 32Twin prime
7, 1111 − 74Cousin prime
23, 2929 − 236Sexy prime
89, 9797 − 898Even prime gap

FAQ

What is a prime gap?

A prime gap is the difference between two consecutive prime numbers.

Why are most prime gaps even?

All primes greater than two are odd. The difference between two odd numbers is even.

What is a twin-prime gap?

A gap of two creates a twin-prime pair, such as 11 and 13.

What is a record prime gap?

It is a gap larger than every earlier gap encountered in the generated sequence.

Can I search for a specific gap?

Yes. Enter a value in the exact gap filter before calculating.

Can I export my calculations?

Yes. Use the CSV or PDF download buttons above the results.

Related Calculators

Average Calculator StatisticsGeometric Mean CalculatorInter Quartile Range CalculatorLower Quartile CalculatorMaximum CalculatorMean Calculator StatisticsMedian Calculator StatisticsMidhinge Calculator StatisticsMid Range Calculator StatisticsMinimum Calculator Statistics

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.