Sieve and Let Spi’

What is VDSP? Inter alia, it’s the complicated consonant-cluster you get when you carefully pronounce the phrase “sieved spiral”. And here is a sieved spiral:

An Ulam Spiral of primes represented on a square grid


The pattern above is called an Ulam spiral (OO-lam) after its inventor, the Polish-Jewish mathematician Stanisław Ulam (1909-84). The white squares represent the prime numbers as you spiral counter-clockwise on a square grid — the little boot or reversed-L in the middle is the only time that filled squares are in direct contact, because it includes square #2, the only even prime. #2 is the heel of the boot, with #3 as the shaft and #11 as the toe.

But the Ulam spiral could also be called a sieved spiral, because you can build it by using the Sieve of Erastosthenes, whose invention is attributed to the Greek scholar Eratosthenes of Cyrene (c. 276–c. 194 BC). Create a list of whole numbers skipping 1. Then choose the first number on the list, which is 2. Cross out every higher number that’s divisible by 2. Then choose the next number that isn’t crossed out. It’ll be 3. Cross out every higher number that’s divisible by 3. Then choose the next available number, 5, and cross out all higher numbers divisible by 5. When you’ve crossed out everything you can, you’ll be left with just prime numbers. Here’s an animation of the Sieve from Wikipedia:

Animated Sieve of Erastosthenes from Wikipedia


Now we can sieve-and-let-spi’, as it were. First create a square grid with white squares. Choose the square in the middle as #1 and fill it it. Then choose white square to the right of #1 and call it #2. Then spiral outwards counter-clockwise filling with black all squares whose count is divisible by 2. Then do that for squares #3, #5, #7, #11 and so on. In the end, the only white squares on the grid will be the primes. And you’ll have a sieved Ulam spiral:

Sieving a spiral — creating the Ulam spiral using the Sieve of Eratosthenes


You can also sieve and let spi’ in reverse, blacking the squares using primes from higher to lowest. With this method, the sieved spiral looks like this:

Sieving a spiral — creating the Ulam spiral using the Sieve of Eratosthenes (higher primes first)