CS 117, Winter 1997

Assignment 3: Perfect

The due-date for this assignment is a little bit weird. I want you to have it done in time for lab on Monday, but if you realize as a result of the lab that you need to fix it up, you'll have until noon on Tuesday to finish it. You may work with a partner for this assignment. No groups of three or more. When you are done with this assignment, please submit it using the Homework Submission Program.

Perfect numbers

Number theorists usually start their lives as number fanatics. They'll do all sorts of weird things to numbers in search of interesting patterns. One of the many such weird things they have done over the centuries is to add up the factors of integers. For example, the sum of the factors of 12 is 1 + 2 + 3 + 4 + 6 = 16, while the sum of the factors of 8 is 1 + 2 + 4 = 7. (Note that we're only adding up the "proper" factors--that is, all the factors other than the number itself.)

After number theorists have played a game like this for a while, they start naming things. Any number whose factors sum to something larger than the number is called abundant, and any number whose factors sum to something smaller than the number are called deficient. Thus, 12 is abundant, while 8 is deficient.

A number whose factors add up to the number itself is something special. The Pythagoreans of the sixth century BC, who were fond of attributing mystical significance to unusual numerical patterns, called such numbers perfect. The number 6 is the smallest perfect number, and 28 is next. Check them out to make sure you understand how numerical perfection works.

Your task

Implement the function IsPerfect, adhering to the following interface:

{
    IsPerfect returns true if its parameter is a
	perfect number, and false otherwise.
}
function IsPerfect( n : integer ) : boolean;

On Monday in lab, you'll use your IsPerfect() function. More accurately, someone else will use your IsPerfect(), and you will use theirs, so do your best to adhere to the interface.

Start early, keep in touch, and have fun.



Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057
(507) 646-4364, jondich@carleton.edu