Gaussian Prime Spirals

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram CDF Player or other Wolfram Language products.

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

Start a loop with a point having integer coordinates in the complex plane (called a Gaussian integer) and trace a path as follows:


• Move right until a Gaussian prime is encountered, then turn left 90°.

• Continue, always moving straight in the current direction until a Gaussian prime is encountered, and again turn left 90°.

The loop ends when the path returns to , facing right.

For this Demonstration, the first point in the cycle is taken to be the first Gaussian prime to the right of the Gaussian integer nearest the locator. From that point, the path goes right and is colored red; the path eventually ends at the start, again colored red. Because the path can overlap itself, the colors can be hidden.

Drag the locator to change the starting position, but note that if the locator is outside the circle of radius 40, it is moved by radial shrinking to a Gaussian integer near that circle.


Contributed by: Joseph O'Rourke and Stan Wagon (April 2012)
(Smith College and Macalester College)
Open content licensed under CC BY-NC-SA



The problem of whether all initial values lead to closed cycles was first raised in [1]. It is related to the open question: Does every horizontal line contain infinitely many Gaussian primes? This is a consequence of the far-reaching hypothesis H of Schinzel [2]. But even if the horizontal line conjecture is true, it is not clear that starting points always cycle.

Within the square bounded by ±100, the largest cycle has length 4820 and starts at . The largest cycle in a search bounded by ±500 starts at and has length 316628. The starting value leads to a walk with 3,900,404 steps.


[1] Gaussian prime spirals, MathOverflow question 91423

[2] Wikipedia entry on Schinzel's hypothesis H

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.