CSci 170: Analysis of Programming Languages

Sieve Demo

Our text discusses an Object-Oriented approach to finding prime numbers by means of the sieve of Eratosthenes. It's given in C++ in the text. Here's the equivalent program in Java. The program doesn't have any comments for documentation. We'll discuss it in class, and you can see the text for details.


SieveDemo.java

Item.java

Filter.java

Counter.java

Sieve.java


Here's the beginning of a run of the program:

The list it produces continues on for some time. The whole list of Prime Numbers to 10000 can be found at http://aleph0.clarku.edu/~djoyce/numbers/primes.html


Back to the course page.