# Prime Generation Algorithm in Python

Simon has written a code in Python that generates primes using the finite list from Euclid’s proof that there are infinitely many primes. “Starting with one prime (2) the code uses the finite list to generate a couple more numbers that aren’t in the list but are primes. It may not even get to all the primes in the long run!” There is only one problem with Simon’s algorithm…

Simon has written down Euclid’s proof in his own words first https://imgur.com/ML2tI6n
and then decided to program it in Python.

# Fundamental Theorem of Arithmetic

Simon working on his proof of the Fundamental Theorem of Arithmetic (he got stuck and then searched for existing proofs online).

# Looking for Primes

Simon programmed this grid of numbers and then used Paint to color the numbers in that are multiples of other numbers, an Eratosthenes way to look for prime numbers. When he compared his result to the prime number table that he found online it turned out to be a complete match!

# Trinity Hall Prime Number

Simon saw this pattern in a Numberphile video featuring Tadashi Tokieda and recreated it in Excel, adding colours. There are 30 columns and 45 rows of digits in this picture, which means it is made of 1350 digits – the year that Trinity Hall (in Cambridge) was founded. the bottom is all zeros, apart from a few glitches. The glitches were necessary because the whole thing (reading from right to left, top to bottom) is also one number and it is a prime number!

# Some more pictures of Simon’s everyday notes

Simon often drags his sketchbook to bed to “show me the beauty”, just before I would read a bedtime story to him and his sis. Last time he showed me a short proof of why there’re infinitely many primes. He assumed there were finitely many primes first… I think he learned that from James Grime:

Pi from Prime numbers:

Powers of 2:

# For the love of math

Simon saw an interesting example on Numberphile and came up with a more general formula for a case when a number can never be prime. Later someone noticed in the comments that Simon made a slight mistake and a should not equal 1. The correct formula is thus 1 < a <= n

Simon continues to be fascinated by math, and specifically – sequences and primes. This blog simply can’t keep up with all the math notes he produces on a daily basis and I will only be posting the most interesting picks from now on. I am filing all of his writings according to date in a separate folder and taking pictures, so nothing gets lost. Even when tucked in bed with me lying next to him reading a bedtime story he sits up again to grab his notepad and pencil to illustrate yet another special number, function or sequence and to share those with me. Last night he begged I let him write down just one more thing because he “really wanted to see the beauty of it” and ended up sketching a whole grid of numbers with primes forming nice diagonal lines across the page. I am deeply touched and honoured to be his first audience.

# Numbers as products of primes (a useful calculation practice). And the general beauty of primes.

Simon spent hours calculating – something he’s not particularly fond of if it were simple/ pointless sums, the way schoolkids work. His was not pointless!  He did it with the solemn purpose of expressing natural numbers as products of primes, the atoms of all numbers.

Here a spiral grid where primes form patterns that Simon finds really beautiful, too bad the A4 paper was too small to go on:

And a sequence in which every number is a sum of cubes (more calculations!):