15-5 Prime Patterns

This program demonstrates how patterns may appear in the distribution of the prime numbers. The program does the following:

  1. Lays out the consecutive integers in a square, one per point, along one of several possible paths:
    • Spiralling outward in the counter-clockwise direction.
    • Diagonally, starting from the upper left corner.
    • Sequentially from left to right, row by row.
  2. Plots each point whose corresponding integer is prime.

Some patterns will appear as diagonal streaks. This is most visible with the spiral path starting with 41.

To run the demo (the controls are at the bottom of the screen):

  1. Enter the size of the side of the square.
  2. Choose the path to lay out the integers.
  3. Enter the starting integer.
  4. Click the Run button.

The initial display will occur automatically.

The original Java Applets do not run in modern browsers, but you can download the Java code and run it locally on your desktop. Check back for JavaScript and Python versions - coming soon!


Download Demos in Java