
Wouldn't it be cool if someone came up with an algorithm for generating prime numbers?
At the start of my PMP journey, I was unaware that this was a hard problem. And by hard, I mean that people far smarter than I have been unable to figure it out.
My initial attempt involved constructing a consecutive prime sequence starting with $\{2,3\}$. I thought I was getting somewhere by adding or subtracting the integer 1 to two consecutive primes. I hoped that a pattern would emerge and determine whether I should add or subtract. But after nothing held up, the only observation that I could make was that prime integers larger than 3 appear to have a form of $6n \pm 1$ for $0\leq n < \infty$
I started to think… How would I go about proving this?
Why am I assuming the construction is linear?
How do I know that $\{2,3\}$ is a sufficient basis?
But I digress... What if someone could prove that the distribution of primes over the positive integers is random? If so, any attempt at devising an algorithm to construct them would prove futile!
With an inmate-secure book (a small laptop) in hand and armed with Python, I wrote a computer program to examine the base two representations of all primes between $2$ and $2^{32}$. I was looking for some feature of their representation that they all shared. An example is thelittle-endian $2^{0}$, which I represent as $\langle 0 \rangle$. But because I didn't want this "trivial" $\langle0 \rangle$ to skew the analysis, I partitioned the primes into sets according to integer size and excluded the endians. I then conducted a frequency analysis on each set.
For example, Jenny's number $(8675309)$ has a representation of $\langle 23, 18, 14, 12, 11, 10, 9, 8, 7, 6, 5, 3, 2, 0 \rangle$. Discarding the endians leaves $\langle 18, 14, 12, 11, 10, 9, 8, 7, 6, 5, 3, 2 \rangle$ remaining. Set 23, which includes Jenny's number and all the other primes between $2^{23}$ and $2^{24}$, was then subject to a frequency analysis.
I wanted to determine if the values within each set were distributed uniformly. In a uniform distribution, not one element of a set appears more or less frequently than any other. This is an important feature of cryptographic algorithms and hash functions. What I hoped to see was that elements within sets of increasing size would approach a near-complete uniform distribution. To measure the distribution, I cut the results of each set's frequency table into two parts and ran a chi-squared test.
The test results showed that as the set size grew, the results of the frequency analysis became increasingly non-uniform. This indicates that there is indeed an underlying structure, and that the distribution of primes over the integers is not random.
I hope this experience might provide an example of why learning mathematics is so interesting. It involves more than computation. Computation is a tool, but there is an underlying theory behind everything that proceeds in logical progression from a set of basic axioms, like a tree growing from a tiny seed, or the universe evolving out of a Big Bang. This progression turns spitballing into a rigorous foundation for future discovery.


