Visualising prime numbers
I came across an interesting post while doom-scrolling Facebook yesterday, which showed an interesting visualisation of the progression of prime numbers in a square spiral.
I thought "that's interesting" and then I thought "I wonder what that would look like as a clock", so I got my robotic slave to build it for me.
It turns out that it's quite cool.
Maths, but in pictures!
I've not done any "serious" maths since school, where I did Maths Statistics at A-level, or possibly University where it occasionally and very rudely intruded into the Economics part of my degree, but I was struck by the idea of an abstract rendering of the current time in a more mathematical way.
There are 86,400 seconds in a day, and apparently there are 8,403 prime numbers less than or equal to 86,400, giving an average of one prime number every 10.28 seconds.
The closest prime numbers on either side of 86,400 are 86,399 and 86,413 (1 second before midnight and 13 seconds into the next day).
Interesting, huh?
So this is what it looks like when you have a full day's worth of seconds elapsed and the primes plotted as a square spiral:

The little red dot down towards the bottom left corner is point number 86,400.
Cool!
Clocks aren't (often) square though...
But what if it were a circular-ish Archimedian spiral rather than a square spiral?

But clocks tick, so we need to make it dynamic - no problem, I have a digital slave for that too!
Here you go - a clock version!
On each of the clock versions you will see the current second as a red cursor - it can be a bit hard to find once the pattern has built out through the day, but it's there!
Now make it do more things!
Ok, maybe we should do a stopwatch version so you don't have to get up at midnight to watch it start!
Also done! Here it is - a stopwatch thingy!
And a version where you can plug in any old range of numbers (up to a total range of 10,000,000 because... memory) so that you can visualise that directly and explore any weird and wonderful quirks of prime number prevalence within a given range that wouldn't show up on a 86,400 point clock version?
Oh, go on then! Here it is - a non time-based prime number visualiser!
Note: Apparently 41 is a bit of a magic number that makes the plotted primes line up with more obvious diagonal lines. Fun!
Dance, AI monkey, dance!
And maybe some other renders? Like, I don't know, a 3D cube? Or a Sacks spiral? Or a Vogel / Fibonacci spiral? Or a Hilbert curve?...
Done that too - just check out the "geometry" options!
And some kind of "tracer" mode where you can see the most recently added primes highlighted in clock or stopwatch mode?
Naturally!
And make all of the parameters explicit in the URL querystring so they're sharable in the event that someone finds / creates something interesting?
Obviously that's done - how do you think all the URLs above work?!?
So there we go - there's a new prime number clock / visualisation tool added to my other clock experiments.
Wasn't that fun, children?
So you see, AI can be fun and helpful when it's not stealing jobs from squishy-brained humans!
If you found it fun and/or interesting, or want to suggest some other geometries to try (just none of those Cthulhu-adjacent non-Euclidian ones that break the walls of reality, please), then why not drop me an email!
Anyway, I need to stop now, because I've been a very busy but also very lazy vibe-coder, and have used all of my Claude tokens up for this 5-hour block and probably 15% of my weekly quota just iterating on a 1,500 line web page experiment for something that randomly caught my attention last night, and I have other things to do that are apparently real and important in the real world...
Updates
Friday 11 September 2026
OK, so the important real-world things were important and real, but I also put some some more time into improving the prime number visualisations a bit, because... well, what else are AI slaves for when you're not actively working on anything else and can get it to churn away on a few improvements while you're sitting on motorways or tallking to estate agents or sorting out deceased family members belongings, and stuff?
New stuff
- Light and dark themes
- Improved zoom and orientation controls for the visualisations — you can click the X/Y/Z visualisation in the bottom left of any 3D visualisation mode to reset it to the original point of view, and slide the zoom slider to zoom in / out on a logarithmic scale.
- The ability to identify any given prime within the visualisations by mousing over them (only on desktop, 'cos
:hoverdoesn't exist on touch interfaces)
Observations
- The "Cube spiral" visualisation is interesting, particularly because there is one face of the cube that has a very clear "hollow" in it, whereas the others are pretty flat. Kudos to any maths nerds who can tell me why!
- The zoom level on some of the geometric models (especially the logarithmic spiral) gets pretty crazy, especially at high number ranges, effectively making the points invisible at some zoom levels because they become sub-pixel sized.
- The trade-off between being able to "see through" points in the foreground when mousing about in the 3D renders versus the desire to be able to highlight a hovered item by mousing over any part of it rather than its exact center point is a compromise I was happy to make (for now - more tinkering may come...)
- The "hover over a prime to identify it" feature stops working at some levels of points visualised. I don't know what that level is, and I'm fine with that for now!
- I wonder what it would look like if I built a similar visualiser that let you explore the multiples or factors of any given number in 3D space?...
