An Ulam spiral is a way to order the natural numbers so as to demonstrate, visually, that there are sequences with high densities of primes.

"Wait! Don't prime numbers famously elude capture by neat mathematical formulae? Why should any particular layout of the number system generate the appearance of order amongst the primes?"
—You, just now

Good question! Whilst some areas of high prime density are expected, the extent of the sequences that you see in the grid above, as yet, do indeed elude mathematical formulation.

But here's the thing: you can build an Ulam spiral with about 50 lines of JavaScript. Here's how (and, I suppose, why) you might want to do that.

By Sophie Stammers. Find out what else she's up to.