Advanced Prime Gap Calculator

Study prime intervals across custom ranges confidently. Spot large jumps, averages, medians, and sequence behavior. Export findings and visualize gaps for sharper numeric insight.

Calculator Inputs

Prime gaps measure the distance between consecutive primes. This page checks all primes in your selected range, summarizes the gaps, filters rows, and charts the visible sequence.

Example Data Table

Range Start Range End Consecutive Pair Gap Note
2 30 3 and 5 2 Twin prime gap
2 30 7 and 11 4 Cousin prime gap
2 50 23 and 29 6 Sexy prime gap
50 100 89 and 97 8 Larger observed spacing
100 150 113 and 127 14 Notable larger gap

Formula Used

Prime Gap Formula: For consecutive primes pn and pn+1, the gap is:

gn = pn+1 - pn

This calculator first finds every prime inside the chosen range. It then subtracts each prime from the next consecutive prime. After that, it summarizes minimum, maximum, mean, and median gap values.

Common special cases include gap 2 for twin primes, gap 4 for cousin primes, and gap 6 for sexy primes. Larger gaps are also measured directly from the generated sequence.

How to Use This Calculator

  1. Enter a starting integer of at least 2.
  2. Enter the ending integer for the search range.
  3. Optionally set a minimum gap filter.
  4. Choose how many result rows you want displayed.
  5. Set a highlight threshold for large gaps.
  6. Optionally limit results to even gaps only.
  7. Press the calculate button to generate results.
  8. Review the summary cards, result table, chart, and downloads.

Frequently Asked Questions

1. What is a prime gap?

A prime gap is the difference between two consecutive prime numbers. If the primes are 11 and 13, the gap is 2. The calculator measures these distances across your chosen range.

2. Why are most prime gaps even?

Except for the pair 2 and 3, all primes are odd. The difference between two odd numbers is always even. That is why prime gaps after the first pair are generally even numbers.

3. What are twin primes in this calculator?

Twin primes are consecutive primes separated by a gap of 2, such as 17 and 19. This page labels those rows as Twin in the output table for easy identification.

4. What does the minimum gap filter do?

It hides rows below your chosen threshold. For example, if you enter 6, the results table shows only prime pairs with gap 6 or greater, while summary statistics still reflect the full measured sequence.

5. How is the average gap calculated?

The average gap equals the sum of all measured consecutive prime gaps divided by the number of gaps. It gives a quick overview of spacing behavior across the selected interval.

6. Why might my range return very few results?

Small ranges or strict filters can greatly reduce displayed rows. A high minimum gap filter, low row limit, or narrow interval may leave only a few consecutive prime pairs to show.

7. What does the chart display?

The Plotly chart shows the visible gap sequence from the filtered table. Each x-axis label represents a consecutive prime pair, and the y-axis value represents the gap between them.

8. Can I download my results?

Yes. When results are available, you can export the displayed table as CSV or generate a PDF summary. That makes it easier to save, compare, or share your calculations.

Related Calculators

Modular Exponentiation Fast Power CalculatorReverse Euclidean algorithm calculatorfast modular exponentiation calculatorLarge number modulo calculatormodular congruence solverpisano period calculatoreuler totient calculatorgcd calculatorprime number checkersum of divisors

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.