Peter Alfeld, --- Department of Mathematics, --- College of Science --- University of Utah

Eratosthenes of Cyrene

A versatile scholar, Eratosthenes of Cyrene lived approximately 275-195 BC. He was the first to estimate accurately the diameter of the earth. For several decades, he served as the director of the famous library in Alexandria. He was highly regarded in the ancient world, but unfortunately only fragments of his writing have survived. Eratosthenes died at an advanced age from voluntary starvation, induced by despair at his blindness.

Here are some links to Eratosthenes related web pages:

The Sieve of Eratosthenes

Eratosthenes also conceived the "Sieve of Eratosthenes ", a method of identifying prime numbers. If you have a Java compatible browser you can use that sieve right here, from this Applet:

However, your browser does not support Java. If it did you would not see this message! Get a java compatible browser such as Netscape, of a sufficiently advanced version.

What is the Sieve of Eratosthenes?

A prime number is a natural number greater than 1 that can be divided without remainder only by itself and by 1. Natural numbers n that can be divided by a number less than n and greater than 1 are composite numbers. The Sieve of Eratosthenes identifies all prime numbers up to a given number n as follows:

  1. Write down the numbers 1, 2, 3, ..., n. We will eliminate composites by marking them. Initially all numbers are unmarked.
  2. Mark the number 1 as special (it is neither prime nor composite).
  3. Set k=1. Until k exceeds or equals the square root of n do this:
  • Put the remaining unmarked numbers in the sequence on your list of prime numbers.
  • This is exactly what the applet does. If the natural numbers are arranged in a rectangular array than marking the composites gives rise to interesting patterns. The Figure nearby shows one of these patterns (the prime numbers from 2 through 12,743), but seeing the pattern develop is much more interesting than seeing the static final result. Experiment with various options yourself! Click here or on the pattern to see a similar pattern made of boxes 2 by 2 pixels large, forming a 529 by 369 rectangle, and showing all primes up to and including 195197.

    Since this is an educational page I'll give you a home work problem: Explain the vertical streaks that seem to be present in the pattern. Once you are done with that, explain why there are no horizontal streaks! Send me your answer!

    The remainder of this page is

    A User's Guide to the Sieve of Eratosthenes Applet

    A quick tour

    To see how it works, do the following:

    Details of the Operation.

    To Start

    Starting is very simple. You click on the applet.

    To Quit

    Quitting is also very simple. It can be accomplished in a number of ways:

    The Control Panel

    Let's run through the rows of the control panel:

    1. Row 1.
    2. Row 2.
    3. Row 3
    4. Row 4. The text windows give the horizontal and vertical extents extent of the drawing window (in boxes) and the length of the list used in the sieve. You can resize the drawing window by specifying the horizontal and vertical extents in the text windows.
    5. Row 5. I increase the version number whenever there is a significant change in the code, by an amount roughly proportional to the change. If you are using an old version then you should probably replace it with the newer version provided here (see the downloading instructions below). The Run # is the total number of runs since November 1, 1996, by all copies of the program, to date. I'm not trying to spy on you, but I am curious how much the program is used, and I'm also fascinated by the technology. The count is obtained by sending an inquiry to my system which returns the current count. This ability to communicate over the net opens a lot possibilities which are as yet not even recognized. If my server daemon is down the program runs fine without indicating a count.

    The Drawing Window

    You can resize the drawing window in several ways:

    You can also control the drawing action via the key board as follows:

    Getting the most out of your applet.

    To compute the largest possible range of primes on your machine do the following:

    1. Click on "reset" or otherwise make sure the drawing has stopped.
    2. Set "size" to 1.
    3. Make the drawing window as large as possible, and lower the window, or close it.
    4. Click on "resize".
    5. Set the delay to zero and click on "do it all! ", or with the cursor in the drawing window type "d" and "a".

    On my machine this process gives rise to a window that 1254 by 894, with n=1,121,075..

    Running Standalone and Downloading

    You may download the byte code of this software and incorporate it into your own web pages or run it on your system in a standalone mode. You need the following Java classes:

    When you click on these links (which point to binary files) you'll probably see something strange on your system. However, you should be able to download the files properly in spite of their appearance.

    Sieve is the class that calls all others. To run the software in standalone mode on a Unix system just type java Sieve in the directory that contains your class files. If you want to base an Applet on your files make sure you specify the code base (the directory containing your class files) similarly as in the html code of this page. The code base must be accessible over the net, otherwise you get a security exception and things don't work right.

    If you do download the software I invite you to let me know so that I can put you on my mailing list and inform you about future improvements. Of course, also let me know if you have any troubles.

    There is no help information built into the program (at least not yet). This page is intended to be the documentation for the program. So you may want to copy the page, print it, or provide a link to it.

    Known Bugs

    This is a list of known bugs. I'm working on them, but at the moment it's not clear to me how to find and correct them (otherwise I'd fix them immediately). If you have any suggestions, or would like to report other bugs, please write to me!


    [02-Jun-1998]

    Return to Peter Alfeld's Home Page.

    Designed for netscape and Java.