The Density Plot of the Prime Gaps is a Fractal

tl;dr: Inspect the last image below and check out gap-density.R.

I just discovered something that made me smile: As I looked at the density plots of increasing numbers of prime gaps, a fractal emerged.

Allow me to explain.

First I get the prime gaps (basically, the distance between primes) with this perl code:

This returns a list like this:

Then, I say, “perl gaps-simple 10 > gaps-simple-10.txt” to get all the prime gaps below the number 10 into a text file.

Next I inspect this in R (the statistical programming environment –, as such:

For increasing numbers of gaps (shown to 100_000_000), this results in the following graphs.  You can see the self-similar, fractal nature emerge: