alpertron logo

Dario Alpern's site Home Page
Ver sitio en castellano

 ELECTRONICS >> Intel Microprocessors (Spanish only)
 MATHEMATICS >> Calculators | Number Theory | Problems
 PROGRAMS >> Assembler 80386 (downloads) | Java | Games
 CONTACT >> Personal | Comments | Guestbook | Links | Donations

Ulam's Spiral

Do you see any pattern in this graph? You will not believe at first glance that it is generated using prime numbers.

In order to generate it, the numbers are arranged in a spiral, as follows:

13 -- 12 -- 11 -- 10    25
|                 |     |
14    03 -- 02    09    24
|     |     |     |     |
15    04    01    08    23
|     |           |     |
16    05 -- 06 -- 07    22
|                       |
17 -- 18 -- 19 -- 20 -- 21

Then the prime numbers are marked. Note the abundance of diagonals.

In the applet above you can see the spiral made up to 1014. The prime numbers are marked in green.

Move the graph by clicking in the arrows or using the arrow keys. You can obtain more detail or see a larger area using the magnifying glass buttons.

You can also see the position (x, y) in the spiral and the number n of any point of the graph by moving the cursor to that point. The applet shows the equations of the diagonal lines that intersect in the point marked by the cursor (see explanation below).

Move the center by typing a new number (up to 14 digits) in the left input box and press the return key.

Change the starting number in the center of the spiral by typing a new number (up to 14 digits) in the right input box and press the return key. By clicking in the triangle buttons you can increment or decrement this value.

The formula that gives the numbers in the diagonal lines can be expressed using quadratic polynomials. The discriminant (delta) can be seen by clicking in the delta button. The quadratic polynomials are shown in the screen along with their factorization (if posible). In this case it is obvious the the diagonal cannot contain primes, except in exceptional cases (when one factor is 1 and the other is prime). These diagonal lines can be seen in blue by clicking in the parentheses button (that represent the factors).

When the quadratic polynomial cannot be factorized, then its diagonal will contain primes. It is interesting to notice that about half the primes cannot divide any of the values of the polynomial. For instance, when we select the center of the spiral equal to 41 by entering this number in the right input box, we will find a diagonal with a lot of primes in the direction NW-SE. This is because the values that take the polynomial 4t2 + 2t + 41 cannot divide 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 or 37 among other prime numbers. Any number in the diagonal line less than 412 = 1681 must be prime, because it is not multiple of any prime less than its square root.

The numbers shown at the right of the polynomial are the primes less than 100 that cannot divide any value of the polynomial.

Last updated February 15th, 2003.