Abundant Numbers

 

For any natural number (i.e., nonnegative integer) m, let f(m) be the sum of the positive divisors of m, not including m itself. As examples,

 

f(28) = 1 + 2 + 4 + 7 + 14 = 28    :PERFECT

 

f(18) = 1 + 2 + 3 + 6 + 9 = 21     :ABUNDANT

 

f(21) = 1 + 3 + 7 = 11             :DEFICIENT

 

If m = f(m), m is said to be PERFECT; if m < f(m), m is said to be ABUNDANT; if m > f(m), m is said to be DEFICIENT.

 

 

Develop a program that, given a positive integer m, reports whether m is ABUNDANT, PERFECT, or DEFICIENT.

 

EXTRA CREDIT:  also indicate if a number m, is prime.

 

 

Input: prompt the user for a positive integer.  Program should run until the user chooses to stop entering numbers by typing the word ÒendÓ.

 

Output: For each number given as input, report on a single line whether it is abundant, perfect, or deficient. See sample output below for exact formatting.

 

Sample input             Corresponding output

----------------            --------------------

18                                         12 is abundant

 

28                                         28 is perfect

 

21                                         21 is deficient

 

Click this link to download a copy of this assignment

 

Go back to Computer Programming Page