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 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:, a container class
See also: Example programs written in Cleanroom style
Previous: My Cleanroom naming conventions
Site map
John W. Shipman,
Last updated: 1997/06/05 23:52:16