Two numbers p and q are twin primes if they are primes and |p – q | = 2.
In the visualization below, I’m drawing the prime numbers in two shades of green. Twin primes in light green and regular primes in dark green.
The “vortex effect” is created because every twin prime is followed by its twin two steps before in the spiral. Below the same image with the zoom in the center:
In the HTML5 demo in Javacriptthe spiral is draw dynamically in a image (warning: it can be a little bit computationally intensive for your machine). You can play with the source-code on Github, and change the parameters. If you are looking for a plain ulam spiral, here it is one.
Update (May 30, 2013): This post was featured on the Blog of Math Blogs.
Update (November 25, 2013): I created a standalone Github project for this code.