Perfect, abundant and deficient numbers
Add up everything that divides a number except itself — if the total lands exactly on the number, it's perfect.
The aliquot sum
Pick a number and list its proper divisors — every whole number that divides it evenly, except the number itself. Add them up. That total has a name: the aliquot sum.
Take 28. Its proper divisors are 1, 2, 4, 7 and 14. Add them: 1 + 2 + 4 + 7 + 14 = 28. The sum comes back to 28 exactly. Numbers that do this are called perfect.
If you already know σ(n), the sum of all divisors including the number itself, the aliquot sum is just σ(n) minus n — you simply leave the number out.
Perfect, abundant, deficient
Comparing the aliquot sum to the number itself sorts every whole number into three camps. Perfect: the sum equals the number, like 6 (1+2+3) and 28. After those the next two are 496 and 8128 — they get rare fast.
Abundant: the sum overshoots. 12 has proper divisors 1, 2, 3, 4, 6, which add to 16 — more than 12, so 12 has a little to spare.
Deficient: the sum falls short. This is the common case — most numbers are deficient. Every prime is the extreme example: its only proper divisor is 1, so its aliquot sum is just 1, far below the number itself.
Why perfect numbers are so rare
Perfect numbers are scattered thinly, and there's a beautiful reason. The Euclid–Euler theorem says every even perfect number is built from a Mersenne prime — a prime of the form 2^p − 1, one less than a power of two.
Whenever 2^p − 1 is prime, the number 2^(p−1) × (2^p − 1) is perfect. For 28 that's 4 × 7, where 7 = 2^3 − 1 is the Mersenne prime. Every even perfect number, with no exceptions, comes from this recipe.
So hunting for even perfect numbers is exactly hunting for Mersenne primes. The largest known primes today are Mersenne primes, turned up by the distributed GIMPS project. Whether any odd perfect number exists is still an open question — none has ever been found.