dmcgrath / ulam

Twin primes visualized over an Ulam Spiral in HTML5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twin primes visualized over an Ulam Spiral

Two numbers p and q are twin primes if they are primes and |p – q | = 2.

The Ulam spiral, discovered by the mathematician Stanislaw Ulam in 1963, is a simple method to visualization prime numbers. Put the numbers in a spiral and draw only the ones which are primes.

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.

twin primes ulam spiral

This “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:

twin primes ulam spiral

in HTML5

[http://silveiraneto.net/wp-content/uploads/2013/05/twin_primes_ulam_spiral.html](HTML5 demo with Canvas + Javacript). Be aware that this page can be computational intensive and freeze your browser for a few seconds.

try it yourself

git clone https://github.com/silveira/ulam

And open the html files in a modern browser.

This content was posted originally on my personal blog.

About

Twin primes visualized over an Ulam Spiral in HTML5

License:GNU General Public License v3.0