Inspired by the graphics used in Prime Climb, specifically the colouring sheet, I did some playing around with LuaTeX and made this. It uses Lua to generate TikZ code in a LuaTeX document. Build using lualatex.
The code takes a number target
and draws and coloured circles for numbers up to target
. Primes are coloured different colours (see caveat below) and then composite numbers are divided into sections coloured using the colours of their prime factors.
Either
- set
target
and let the next line setrowlength
to be the square root oftarget
rounded down, for a rougly-square grid; or, - set
rowlength
and settarget
to be some multiple ofrowlength
, for example to create a rectangle grid of fixed row length.
A bunch of colours are hard-coded into a list which are used to colour the primes in sequence. Issues with this:
- there are fewer colours than there are prime numbers (hard to fix);
- colours could be checked to be more distinct and in a better order, so adjacent primes are definitely differently-coloured.
A partial-fix for 1. is that when the list of colours is exhausted, the code uses runoutofcolour
for all remaining primes. An issue with this is that if primes p1 and p2 are coloured the same, their product p1p2 (if it appears in the grid) will be coloured in two halves using the same colour for each half.
Things that could be done:
- sort out the colours that are used;
- add more colours to the list;
- come up with a programmatic way to generate distinct colours for new primes to replace this list.
This colours segments in numerical order starting at the top of the circle and moving anticlockwise, e.g. 100 is coloured using the colours for 2, 2, 5, 5 in that order. If you are hoping for children to understand prime factors, it may be better to colour differently, e.g. colouring 100 as 2, 5, 2, 5 would more clearly indicate it is 10^2. Also you might like to colour in numerical order going clockwise instead of anticlockwise.
Actual Prime Climb doesn't always start drawing segments at the top of the circle. For example, compare 4, 8 and 16. I don't know if this really matters, because I am not trying to duplicate Prime Climb graphics, just playing around with colouring in.