UKSPC Practice Problems » Perfect Numbers

For any number N, if the sum of N's divisors, excluding N itself, equals N, the number is called perfect. If the sum is less than N it is called deficient. If the sum is greater than N it is called abundant. Examples:

• 6 has divisors 1, 2, and 3.
1 + 2 + 3 = 6
6 = 6
Therefore 6 is perfect.
• 8 has divisors 1, 2, and 4.
1 + 2 + 4 = 7
7 < 8
Therefore 8 is deficient.
• 24 has divisors 1, 2, 3, 4, 6, 8, and 12.
1 + 2 + 3 + 4 + 6 + 8 + 12 = 36
36 > 24
Therefore 24 is abundant.

Write a program that will read in a number and classify it as perfect, deficient, or abundant.

Input Specification

Input will consist of a series of numbers, one per line. The input will be terminated by zero (0).

Output Specification

Output will consist of one line for each number in the input file and will echo the original number followed by the sum (both right justified in fields of width 4 columns) followed by one of the words 'perfect', 'deficient' or 'abundant', as shown in the example.

```6
8
24
0```

Sample Output

``` 6   6    perfect
8   7  deficient
24  36   abundant```