How this calculation works
A perfect number equals the sum of its proper divisors. For example, 6 = 1+2+3.
Compare the sum of proper divisors with nA worked example
The proper divisors of 12 sum to 16, so it is abundant.
Good to know
For 1 the proper-divisor sum is zero.
Reference: NIST DLMF, Functions of Number Theory (opens in a new tab) ↗
Add the divisors below the number itself
The proper positive divisors of 12 are 1, 2, 3, 4 and 6. Their sum is 16, exceeding 12 by 4. The default classification is therefore Abundant. Proper divisors include 1 but exclude the original number.
A proper-divisor sum below the input gives Deficient, while equality gives Perfect. Six is perfect because 1 + 2 + 3 = 6. Eight is deficient because 1 + 2 + 4 = 7. These examples show all three branches of the classification and can be checked by changing the input.
Subtract the input from the full divisor sum
The Sum of positive divisors calculator includes the input itself. For 12 it returns 28, and subtracting 12 leaves the proper-divisor sum 16. This implementation uses prime factorization to compute the full sum before making that subtraction.
One has no positive divisor below itself, so its proper-divisor sum is the empty sum zero and it is deficient. Every prime is also deficient because its sole proper positive divisor is 1. Composite status alone does not determine the classification, as the examples 6, 8 and 12 demonstrate. The classification concerns positive integer divisors, so fractional or negative divisors are not included.
A few questions, answered
Does abundant mean the number has many divisors?
The definition uses their sum. It requires the proper-divisor sum to exceed the original number.
Why is 28 perfect?
Its proper divisors 1, 2, 4, 7 and 14 sum to 28.