Next / Previous / Shipman's Home Sweet Homepage / Site map

Cleanroom examples: Prime number testing

This is a small object illustrating numerical programming in the Python language. Module prime.py defines a class Prime. The purpose of a Prime object is to work with prime numbers---to test numbers for primality, and to find the set of prime factors in a given number.

We could just provide simple functions for primality testing and factoring. However, the process of testing a number for primes involves generating primes. For efficiency's sake, we provide an object that remembers all the primes it has already generated, rather than discarding them.


Next: Cleanroom examples: skiplist.py, a container class
See also: Example programs written in Cleanroom style
Previous: My Cleanroom naming conventions
Site map
John W. Shipman, john@nmt.edu
Last updated: 1997/06/05 23:52:16
URL: http://www.nmt.edu/~shipman/soft/clean/prime.html