PrimeSpiral is a demonstration applet with no utility value.

The concept of the prime spiral is simple: start at the center of a square and spiral outwards, inverting bits whose positions correspond to prime numbers. (Click here for a close up detail drawing that might explain this a litte better.) Since there's no formula to produce primes, they're found by algorithm, you'd expect the pattern to be random (~ 10% gray shade, roughly the frequency of primes). What you get instead are numerous broken diagonal lines, voids and other patterns. Let your imagination and intuition figure out why:

GIF Image of Prime Spiral output
(You don't have a Java-capable browser so here's a static view of the output.)

The prime spiral tests how efficiently your workstation (and programmer) can compute primes and plot single bit data points on a graphic display. (Click here for the history of this program.) You can either start with zero as your center (like this implementation) or one, it doesn't affect the pattern much nor does the direction you spiral.

Java Source Code: the Applet, the PrimeGenerator class and the SpiralGenerator class.

- Christopher Lane

Return to my home page.