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 prime machine finds prime numbers using the Sieve of Eratosthenes and lets you study and explore those prime numbers.
When you first click on the above applet a control window pops up. It should look like this:
The most important item in that window is the text field in the center of the second row, the one with the fetching dark red background. Everything happens with respect to the number in that field. Let's call it N. Initially, N=100 (that value lets you explore the prime numbers in a familiar range).
Let's go though the rows of the control panel.
When starting up the applet computes all prime numbers from 2 to 2N. It does this by using a modification of the Sieve of Eratosthenes that only considers odd numbers and is about twice as fast and uses half as much memory as the original sieve. As mentioned above, the default value of N is 100. If the value of N (perhaps entered though the textfield) exceeds the range of numbers covered a new computation is started automatically. The larger the new value of N, the longer the computation will take, and the more memory it will require.
number of primes <= N lim --------------------- = 1. N-->infinity N/log(N)where log denotes the natural logarithm. It is pretty amazing to have such a tight connection exists between areas of mathematics (logarithms and prime numbers) that seem so disparate! For more information consult any text on Number Theory, for example those listed on my Prime Number Page.
Unfortunately, the ratio N/log(N) behaves very much
like a linear function, so the large scale behavior of prime
numbers is not readily apparent. You can display the number
of prime twins, phi, and N/log(N) by
pressing the yellow draw button in the first row of the
control panel. (Press the button again to make the drawing
disappear.)
For N=10,000 you get the display illustrated in the nearby figure. N varies along the horizontal axis. Red indicates the number of prime twins, green the approximation x/log(x) (counted from the horizontal axis, and blue the actual number of primes (also counted from the horizontal axis). Think of red being in front of green, and green in front of blue. You can only see the top of blue and the top of green, but all of red. According to the prime number theorem, in the limit as N tends to infinity green and blue become identical. It also appears from the picture that the number of prime twins grows linearly with N which, if true, would imply that there are infinitely many prime twins. Click here or on the picture to see the corresponding display for N=100,000,001 which is close to the largest value that I can reasonably handle on my machine. It actually does not look much different, although the blue wedge is a little narrower. You may also like to explore drawing the picture for small values of N, to illustrate the discrete nature of the prime distribution.
Note: If your machine is at all like mine then everything will become sluggish and things may not work quite right if you use a lot of memory. So you may want to be careful about choosing very large values of N.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.
Prime is the class that calls all others. To run the software in standalone mode on a Unix system just type java Prime 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.
Return to Peter Alfeld's Home Page.