You are currently browsing the tag archive for the ‘primes’ tag.

Screen Shot 2021-07-18 at 9.55.30 AM

If you are a teacher then please also visit my new site: for over 2000+ pdf pages of resources for teaching IB maths!

Prime Spirals – Patterns in Primes

One of the fundamental goals of pure mathematicians is gaining a deeper understanding of the distribution of prime numbers – hence why the Riemann Hypothesis is one of the great unsolved problems in number theory and has a $1 million prize for anyone who can solve it.  Prime numbers are the the building blocks of our number system and are essential to our current encryption methods such as RSA encryption.  Hence finding patterns in the primes is one of the great mathematical pursuits.

Polar coordinates

The beautiful prime spiral was generated above on Desmos using polar coordinates.  We can see a clear spiral pattern – so let’s see how to create this.  Polar coordinates (r, θ) need a length (r) from the origin and an angle of anti-clockwise rotation from the origin (θ).  So for example in polar coordinates (2,2) means a length of 2 from the origin and a rotation of 2 radians.  By considering trigonometry and the unit circle we can say that the polar coordinates (r, θ) are equivalent to the Cartesian coordinate (r.cosθ, r.sinθ).

Plotting prime pairs

So we plot the first few prime pairs:

Polar: (2,2).  Cartesian: (2cos2, 2sin2).

Polar: (3,3).  Cartesian: (3cos3, 3sin3).

Polar: (5,5).  Cartesian: (5cos5, 5sin5).

In Desmos (making sure we are in radians) we input:

Screen Shot 2021-07-18 at 10.18.41 AM

We can then change the Desmos graph view to polar (first click on the spanner on the right of the screen).  This gives the first 3 points of our spirals. Note I have labeled the points as polar coordinates.

Screen Shot 2021-07-18 at 10.21.16 AM

I then downloaded the first 1000 prime numbers from here. I then copied this list of comma separated values and pasted it into an empty part of square brackets M = [ ] in Desmos to create a list.

Screen Shot 2021-07-18 at 10.24.41 AM

I can then plot every point in the list as a prime pair by doing the following:

Screen Shot 2021-07-18 at 10.26.27 AM

We can then generate our prime spiral for the first 1000 prime pairs:


Just to see how powerful Desmos really is, I then downloaded all the prime numbers less than or equal to 100,000 from here.  This time we see the following graph:


We can see that we lose the clear definition of the spiral – though there are still circular spirals with higher densities of primes than others.  Also we can see that there are higher densities of the primes on some of the radial lines out from the origin – and other radial lines where no primes appear.

Prime Number Theorem

We can also use our Desmos result to investigate another (more fundamental) result about the distribution of prime numbers.  The prime number theorem states:

Screen Shot 2021-07-20 at 4.54.47 PM

Here pi(N) is the number of prime numbers less than or equal to N.  The little squiggle means that as N gets large pi(N) becomes better and better approximated by the function on the RHS.

For our purple “spiral” above we downloaded all the primes less than or equal to 100,000 – and Desmos tells us that there were 9,592 of them.  So let’s see how close the prime number theorem gets us:

Screen Shot 2021-07-20 at 5.03.27 PM

We can see that we are off by an error of around 9.46% – not too bad, though still a bit out.  As we make N larger we will find that we get a better and better approximation.

Let’s look at what would happen if we took N as 1,000,000,000.  From Wikipedia we can see that there are 50,847,534 primes less than or equal to 1,000,000,000.  Therefore:

Screen Shot 2021-07-20 at 5.11.00 PMThis time we are off by an error of only 5.10%.  Have a look at the table of values in Wikipedia to find how large N has to be to be within 1% accuracy.

So this is a nice introduction to looking for patterns in the primes – and a good chance to explore some of the nice graphical capabilities of Desmos.  See if you can find any more patterns of your own!

Essential Resources for IB Teachers


Screen Shot 2021-08-21 at 1.07.49 PM

If you are a teacher then please also visit my new site.  This has been designed specifically for teachers of mathematics at international schools.  The content now includes over 2000 pages of pdf content for the entire SL and HL Analysis syllabus and also the SL Applications syllabus.  Some of the content includes:

  1. Original pdf worksheets (with full worked solutions) designed to cover all the syllabus topics.  These make great homework sheets or in class worksheets – and are each designed to last between 40 minutes and 1 hour.
  2. Original Paper 3 investigations (with full worked solutions) to develop investigative techniques and support both the exploration and the Paper 3 examination.
  3. Over 150 pages of Coursework Guides to introduce students to the essentials behind getting an excellent mark on their exploration coursework.
  4. A large number of enrichment activities such as treasure hunts, quizzes, investigations, Desmos explorations, Python coding and more – to engage IB learners in the course.

There is also a lot more.  I think this could save teachers 200+ hours of preparation time in delivering an IB maths course – so it should be well worth exploring!

Essential Resources for both IB teachers and IB students

1) Exploration Guides and Paper 3 Resources

Screen Shot 2021-12-01 at 1.19.14 PM

I’ve put together a 168 page Super Exploration Guide to talk students and teachers through all aspects of producing an excellent coursework submission.  Students always make the same mistakes when doing their coursework – get the inside track from an IB moderator!  I have also made Paper 3 packs for HL Analysis and also Applications students to help prepare for their Paper 3 exams.  The Exploration Guides can be downloaded here and the Paper 3 Questions can be downloaded here.

prime array 4

How Are Prime Numbers Distributed? Twin Primes Conjecture

Thanks to a great post on the Teaching Mathematics blog about getting students to conduct an open ended investigation on consecutive numbers, I tried this with my year 10s – with some really interesting results. My favourites were these conjectures:

1) In a set of any 10 consecutive numbers, there will be no more than 5 primes. (And the only set of 5 primes is 2,3,5,7,11)
2) There is only 1 example of 3 consecutive odd numbers all being primes – 3,5,7

(You can prove both in a relatively straightforward manner by considering that a span of 3 consecutive odd numbers will always contain a multiple of 3)

Twin Prime Conjecture

These are particularly interesting because the study of the distribution of prime numbers is very much a live mathematical topic that mathematicians still work on today. Indeed studying the distribution of primes and trying to prove the twin prime conjecture are important areas of research in number theory.

The twin prime conjecture is one of those nice mathematical problems (like Fermat’s Last Theorem) which is very easy to understand and explain:

It is conjectured that there are infinitely many twin primes – ie. pairs of prime numbers which are 2 away from each other. For example 3 and 5 are twin primes, as are 11 and 13. Whilst it is easy to state the problem it is very difficult to prove.


However, this year there has been a major breakthrough in the quest to answer this problem. Chinese mathematician Yitang Zhang has proved that there are infinitely many prime pairs with gap N for some N less than 70,000,000.

This may at first glance not seem very impressive – after all to prove the conjecture we need to prove there are infinitely many prime pairs with gap N = 2. 70,000,000 is a long way away! Nevertheless this mathematical method gives a building block for other mathematicians to tighten this bound. Already that bound has been reduced to N <60,744 and is being reduced almost daily.

Prime Number Distribution

Associated with research into twin primes is also a desire to understand the distribution of prime numbers. Wolfram have a nice demonstration showing the cumulative distribution of prime numbers (x axis shows total integers x100)

prime array 3

Indeed, if you choose at random an integer from the first N numbers, the probability that it is prime is approximately given by 1/ln(N).

We can see other patterns by looking at prime arrays:

prime array

This array is for the first 100 integers – counting from top left to right.  Each black square represents a prime number.  The array below shows the first 5000 integers.  We can see that prime numbers start to “thin out” as the numbers get larger.

primae array 2The desire to understand the distribution of the prime numbers is intimately tied up with the Riemann Hypothesis – which is one of the million dollar maths problems.  Despite being conjectured by Bernhard Riemann over 150 years ago it has still to be proven and so remains one of the most important unanswered questions in pure mathematics.

For more reading on twin primes and Yitang Zhang’s discovery, there is a great (and detailed) article in Wired on this topic.

If you enjoyed this topic, you may also like:

A post on synesthesia about how some people see colours in their numbers.

A discussion about the Million Dollar Maths problems (which includes the Riemann Hypothesis).

Essential resources for IB students:

1) Exploration Guides and Paper 3 Resources

Screen Shot 2021-05-19 at 6.32.13 PM

I’ve put together four comprehensive pdf guides to help students prepare for their exploration coursework and Paper 3 investigations. The exploration guides talk through the marking criteria, common student mistakes, excellent ideas for explorations, technology advice, modeling methods and a variety of statistical techniques with detailed explanations. I’ve also made 17 full investigation questions which are also excellent starting points for explorations.  The Exploration Guides can be downloaded here and the Paper 3 Questions can be downloaded here.

Website Stats



All content on this site has been written by Andrew Chambers (MSc. Mathematics, IB Mathematics Examiner).

New website for International teachers

I’ve just launched a brand new maths site for international schools – over 2000 pdf pages of resources to support IB teachers.  If you are an IB teacher this could save you 200+ hours of preparation time.

Explore here!

Free HL Paper 3 Questions

P3 investigation questions and fully typed mark scheme.  Packs for both Applications students and Analysis students.

Available to download here

IB Maths Super Exploration Guide

A Super Exploration Guide with 168 pages of essential advice from a current IB examiner to ensure you get great marks on your coursework.

Available to download here.

Recent Posts

Follow IB Maths Resources from Intermathematics on