How to Check Whether a Number Is Perfect
At a glance
- 1. List proper divisors
Find the positive divisors of n, leaving n itself out.
- 2. Add the divisors
Calculate their sum, using divisor pairs up to the square root to save time.
- 3. Compare with n
The number is perfect exactly when the proper-divisor sum equals n.
- 4. Use a factorization
For a known prime factorization, compute the divisor sum with the sigma formula.
A perfect number is a positive integer equal to the sum of its positive divisors other than itself. You can check a particular number by finding and adding those proper divisors. For larger numbers, pairing divisors or using the prime factorization avoids listing every divisor one by one.
The method works for any positive integer. It also clarifies a useful equivalent test: the sum of all positive divisors must be twice the number.
Definition and equivalent test
Write for the sum of the proper positive divisors of . Then is perfect precisely when
If denotes the sum of all positive divisors, including , then . Therefore the same test can be written as
For example, the proper divisors of 6 are 1, 2, and 3. Their sum is 6, so 6 is perfect. The number 1 is not perfect: it has no proper positive divisors, so their sum is 0.
Check by pairing divisors
For a number , each divisor is paired with . One member of the pair is at most , and the other is at least . This means you only need to test possible divisors up to the square root.
Use this procedure:
- Start the proper-divisor sum at 1 for ; 1 is always a proper divisor of such a number.
- For each integer from 2 through , check whether divides .
- If it does, add both and to the sum.
- If is a square and , add that divisor only once.
- Compare the result with .
For , the divisors found from the test values are and , and and . Including 1 gives
Thus 28 is perfect. The test did not need to check values above , because any larger proper divisor would have a matching divisor below the square root.
As a square-number example, take . The proper divisors are , whose sum is 55. When testing up to , the pair for is just itself; counting it twice would give the wrong sum. Since 55 is not 36, the number is not perfect.
Use the prime factorization
If you know the prime factorization
you can calculate the sum of all divisors without listing them:
Then check whether . For 28, the factorization is , so
Therefore 28 is perfect. This formula is particularly convenient when a number has few prime factors, though finding the factorization can itself be difficult for very large numbers.
A shortcut for even perfect numbers
There is a special characterization of even perfect numbers: an even integer is perfect exactly when it has the form
where both and the Mersenne number are prime. For instance, gives . This shortcut is useful when checking candidates of that form. It does not settle whether any odd perfect numbers exist; that remains an open problem. The divisor-sum test still applies to any specific odd number you want to check.
Common mistakes
- Including among the proper divisors. The proper-divisor sum excludes the number itself. If you use instead, compare it with .
- Counting a square-root divisor twice. When is a square, its square root pairs with itself and should be added once.
- Checking divisors only up to without a reason. That method can work, but testing up to and adding divisor pairs is usually faster.
- Assuming a familiar form proves perfection automatically. For the even-number characterization, verify that both and are prime.
For a single moderate-sized integer, the divisor-pair test is straightforward. For a number already factored into primes, the sigma formula is often shorter.
References
- Elementary Number Theory, David M. Burton
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.