Home

[only for numbers up to 100 and, may max your browser]

Ulam's spiral is named after Stanislaw Ulam, who wrote the counting numbers 1, 2, 3, 4, etc in a spiral and then circled the primes. He noticed the primes tend to form diagonal lines. In the image above, the primes are printed in black, while non-primes are grey, so darker diagonal lines of primes can be seen. [Primes generated by various quadratics are shown in colour - see below for more about this.] For a more vivid image of the lines, click the 'switch numbers on/off' button. The primes will then be represented by squares.

The size of each square is double the number entered, minus one. So for example, starting with 15 gives a 29 by 29 square with 841 numbers. When 25 or above is entered (giving 2401 or above numbers), the square is automatically shown with the numbers replaced by squares. You can override this with the 'switch numbers on/off' button for numbers up to 100. The image is not calculated for numbers above 157, so the maximum square size contains just under 100000 elements.

The quadratic 4x2 - 2x + 41 generates an unusual proportion of primes. This can be seen by the presence of one of the diagonal lines which appears in this colour, particularly visible for n above 25. Some of the other diagonal lines are highlighted in other colours, see below.