Problem E
Abundant, Deficient, and Perfect Numbers
Recall that a divisor
Formally, let
A number is abundant if the sum of its divisors, other than
itself, is larger than the number itself, deficient if the sum
of divisors is lower, and perfect if the sum of divisors equals
the number. For example,
Write the function sum_of_divisors(number), which takes as an
argument an integer
Now, write a second function decide(number). This function receives as a
parameter an integer
-
“{n} is abundant.” if the sum of the divisors of
are greater than itself. -
“{n} is deficient.” if the sum of the divisors of
is less than itself. -
“{n} is a perfect number.” if the sum of the divisors of
is equal to itself.
Note that we are testing your code differently in this task, please only submit your function definitions, without any code outside the functions! The main python file, which handles input and output, is already provided. You can download and place the main file in the same directory as your python file. You can then run the main python file we provide to try out the samples.
Note that only the function decide will be tested, but you should make that function delegate some of the work it needs to perform, by calling the other function, sum_of_divisors.
Input
The input to the function decide
will consist of one integer
Output
The output of the function should be one string, containing the verdict as described above.
Sample Input 1 | Sample Output 1 |
---|---|
6 |
6 is a perfect number. |
Sample Input 2 | Sample Output 2 |
---|---|
10 |
10 is deficient. |
Sample Input 3 | Sample Output 3 |
---|---|
66 |
66 is abundant. |