All projects

Prime gaps

A C++ sieve generates 148,933 primes and their gaps, and an eight-page Streamlit dashboard explores them, from the Prime Number Theorem and gap statistics to the AKS test and Mersenne primes.

The problem

Primes look random, but the gaps between them follow patterns. I wanted to generate a lot of them quickly and look at them from several angles in one place.

How it works

Results

The sieve produces 148,933 primes. For the first 50,000, the mean gap is 12.24, the largest is 114 and the most common is 6. The gaps are right-skewed (skewness 1.8) and correlate only weakly with the size of the prime (r = 0.16). The animation on this page is the dashboard’s Ulam spiral.

View on GitHub