CCC '96 S1 - Deficient, Perfect, and Abundant

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type

Write a program that repeatedly reads a positive integer, determines if the integer is deficient, perfect, or abundant, and outputs the number along with its classification.

A positive integer, n, is said to be perfect if the sum of its proper divisors equals the number itself. (Proper divisors include 1 but not the number itself.) If this sum is less than n, the number is deficient, and if the sum is greater than n, the number is abundant.

The input starts with the number of integers that follow. For each of the following integers, your program should output the classification, as given below. You may assume that the input integers are greater than 1 and less than 32\,500.

Sample Input


Sample Output

4 is a deficient number.
6 is a perfect number.
12 is an abundant number.


  • 0
    jfan27  commented on May 22, 2024, 5:19 p.m.

    Be careful about the grammar. An abundant number should be "an abundant number." not "a abundant number."

  • 0
    gary4988  commented on Nov. 8, 2021, 10:29 p.m.

    Is 1 a perfect number? or What is 1's proper divisor?

    According to the definition: "Proper divisors include 1 but not the number itself", first we can say that "1 is 1's proper divisor since Proper divisors include 1". We can also say, on the other hand, that "1 is not 1's proper divisor" since 1 is the number itself.

    • 7
      d  commented on Nov. 9, 2021, 12:36 a.m.

      From the problem statement,

      You may assume that the input integers are greater than 1

  • 0
    Nate  commented on Oct. 29, 2020, 3:22 p.m.

    I have a strange comment, kind of related to the question, how many perfect integers are there up until say up until 2,147,483,647? I wrote a program, but in about 15 minutes it only got 4. And those where 6, 28, 496, and 8128. Has anybody else been able to actually get a complete list?

    • 16
      d  commented on Oct. 29, 2020, 6:02 p.m.

      A quick search found a good answer to your question. In case you're too lazy to read the link, I can summarize:

      • If 2^p-1 is prime, then 2^{p-1} (2^p-1) is a perfect number. The first few values of p are 2, 3, 5, 7, 13 and their corresponding values are 6, 28, 496, 8128, 33550336, ...
      • All other even numbers are not perfect.

      The current limitations are:

      • Right now, there are 51 known values of p (the largest is 82589933) and 51 known perfect numbers. We don't know if there are finitely or infinitely many p.
      • It is unknown if any odd numbers are perfect. An odd perfect number must be greater than 10^{1500}.

    • 0
      feliser  commented on Oct. 29, 2020, 5:40 p.m.