Write a test harness for the
code example earlier in this chapter. Make
it as exhaustive as you can. How many individual test cases have
How many of these passed?
How many failed?
Using these tests, identify any faults and repair the code.
There are a large number of tests you should run, even though there are very few invalid input combinations. Thinking of invalid inputs first: Test for zero. It may or may not be an invalid value (we've seen no spec, so we can't tell), but you'd expect the code to cope reasonably with it.
Next, write tests considering combinations of usual inputs (say of 1, 10, and 100 in all orders). Then try numbers with no common multiple, like 733 and ...