Number Theory

Perfect Numbers and Their Link to Mersenne Primes

Learn what makes a number perfect, why every even one comes from a Mersenne prime, and which questions about them are still unanswered.

Key takeaways

  • A perfect number equals the sum of its divisors other than itself, as 6 and 28 do.
  • Euclid showed that a Mersenne prime 2ᵖ − 1 produces the perfect number 2ᵖ⁻¹(2ᵖ − 1).
  • Euler proved the converse for even numbers, so the two lists match one for one.
  • Nobody knows whether infinitely many perfect numbers exist or whether any odd one exists.

A perfect number equals the sum of its proper divisors, meaning all of its positive divisors except itself. The smallest is 6, because 1 + 2 + 3 = 6. The next is 28, since 1 + 2 + 4 + 7 + 14 = 28.

Every even perfect number is tied to a special kind of prime. If 2ᵖ − 1 is prime, then 2ᵖ⁻¹ × (2ᵖ − 1) is perfect, and every even perfect number arises this way. Primes of the form 2ᵖ − 1 are called Mersenne primes, so finding one means finding a new even perfect number.

Deficient, abundant and perfect

Add up the proper divisors of a number and compare the total with the number itself. Three outcomes are possible.

Type Condition Example
Deficient sum is smaller 8: 1 + 2 + 4 = 7
Perfect sum is equal 6: 1 + 2 + 3 = 6
Abundant sum is larger 12: 1 + 2 + 3 + 4 + 6 = 16

Every prime is as deficient as a number can be, with a proper divisor sum of just 1. Perfect numbers are the rare cases of exact balance. The names go back to ancient Greek writers on arithmetic, and Nicomachus, around 100 CE, attached moral meanings to the three classes. The mathematics does not depend on any of that.

The first five perfect numbers are 6, 28, 496, 8128 and 33,550,336. The jump from the fourth to the fifth shows how quickly they spread out.

The divisor sum function

It helps to have notation. Let σ(n), read "sigma of n", be the sum of all positive divisors of n, including n. Then n is perfect exactly when σ(n) = 2n.

For a prime power the divisors are simply the powers.

σ(2⁴) = 1 + 2 + 4 + 8 + 16 = 31 = 2⁵ − 1
σ(2ᵏ) = 2ᵏ⁺¹ − 1
σ(q)  = q + 1                    when q is prime

The function has one more property that matters here. If m and n share no common factor, then σ(mn) = σ(m) × σ(n). The reason is that each divisor of mn splits in exactly one way into a divisor of m times a divisor of n. The article on counting divisors uses the same splitting.

Euclid's construction

The last proposition of Book IX of Euclid's Elements gives the recipe. In modern notation, suppose q = 2ᵖ − 1 is prime and let n = 2ᵖ⁻¹ × q.

σ(n) = σ(2ᵖ⁻¹) × σ(q)          the two parts are coprime
     = (2ᵖ − 1) × (q + 1)
     = q × 2ᵖ
     = 2 × (2ᵖ⁻¹ × q)
     = 2n

So n is perfect. With p = 2 we get q = 3 and n = 6. With p = 3 we get q = 7 and n = 28. With p = 5 we get q = 31 and n = 16 × 31 = 496. With p = 7 we get q = 127 and n = 64 × 127 = 8128.

Euler's converse

Two thousand years later, Leonhard Euler showed that no other even perfect numbers exist. The proof is short enough to follow.

Write an even perfect number as n = 2ᵏ × m with k ≥ 1 and m odd. Perfection says σ(n) = 2n.

(2ᵏ⁺¹ − 1) × σ(m) = 2ᵏ⁺¹ × m

The factor 2ᵏ⁺¹ − 1 is odd, so it shares nothing with 2ᵏ⁺¹ and must divide m. Write m = (2ᵏ⁺¹ − 1) × t. Then σ(m) = 2ᵏ⁺¹ × t, which equals m + t.

Now m and t are both divisors of m, and they are different because 2ᵏ⁺¹ − 1 is at least 3. Their sum already accounts for all of σ(m). So m has exactly two divisors, which means m is prime and t = 1. Therefore m = 2ᵏ⁺¹ − 1 is a Mersenne prime.

From an exponent to a perfect number
1 Pick a prime p A composite exponent can never work 2 Form 2ᵖ − 1 For p = 5 this gives 31 3 Test primality Continue only if the result is prime 4 Multiply 2ᵖ⁻¹ × (2ᵖ − 1), here 16 × 31 5 Perfect number 496 equals the sum of its proper divisors Pick a prime p A composite exponent can never work 1 Form 2ᵖ − 1 For p = 5 this gives 31 2 Test primality Continue only if the result is prime 3 Multiply 2ᵖ⁻¹ × (2ᵖ − 1), here 16 × 31 4 Perfect number 496 equals the sum of its proper divisors 5

When is 2ᵖ − 1 prime?

The exponent itself must be prime. If p = ab with a and b greater than 1, then 2ᵃ − 1 divides 2ᵖ − 1. For instance 2⁶ − 1 = 63 is divisible by 2² − 1 = 3 and by 2³ − 1 = 7.

A prime exponent is necessary but not sufficient. The first failure is p = 11:

2¹¹ − 1 = 2047 = 23 × 89

Most prime exponents fail. The successful ones begin 2, 3, 5, 7, 13, 17, 19, 31. The French friar Marin Mersenne published a list of claimed exponents in 1644, which contained both errors and omissions, yet his name stuck.

There is a remarkably efficient test designed for these numbers, the Lucas-Lehmer test. For that reason the largest known primes have usually been Mersenne primes, and a volunteer computing project, the Great Internet Mersenne Prime Search, has found a string of them. As of the mid-2020s a little over fifty were known, the largest having tens of millions of digits. Counts and records change, so check the project's current list. More detail is in Mersenne primes and record sizes.

Curious properties of even perfect numbers

Every even perfect number is a triangular number, a total of the form 1 + 2 + ... + m. Indeed 2ᵖ⁻¹(2ᵖ − 1) is q(q + 1) ÷ 2 with q = 2ᵖ − 1. So 6 = 1 + 2 + 3, and 28 = 1 + 2 + ... + 7.

In binary they have a striking shape: p ones followed by p − 1 zeros. Thus 6 is 110, 28 is 11100 and 496 is 111110000.

Apart from 6, they are sums of consecutive odd cubes: 28 = 1³ + 3³, and 496 = 1³ + 3³ + 5³ + 7³.

In base ten each even perfect number ends in 6 or 8. And for any perfect number, the reciprocals of all its divisors add to 2. For 6: 1 + 1/2 + 1/3 + 1/6 = 2.

Why the last digit is 6 or 8

The claim about final digits makes a good exercise, because it follows from the Euclid and Euler form. When p = 2, the number is 6. Every other prime exponent is odd, so p leaves remainder 1 or 3 on division by 4.

Powers of 2 have last digits that repeat in the cycle 2, 4, 8, 6. If p leaves remainder 1 on division by 4, then 2ᵖ⁻¹ ends in 6 and 2ᵖ − 1 ends in 1, so the product ends in 6. If p leaves remainder 3, then 2ᵖ⁻¹ ends in 4 and 2ᵖ − 1 ends in 7. Since 4 × 7 = 28, the product ends in 8.

The examples agree: p = 5 and p = 13 give 496 and 33,550,336, ending in 6, while p = 3 and p = 7 give 28 and 8128, ending in 8. Early writers sometimes claimed that the endings alternate strictly between 6 and 8. They do not, since the fifth and sixth perfect numbers both end in 6. A pattern seen in four cases was promoted too quickly, a warning that applies far beyond this topic.

Early writers also guessed that there would be one perfect number with each count of digits. The first four have one, two, three and four digits, and then the fifth has eight.

Why they spread out so fast

Each even perfect number is a little less than half the square of its Mersenne prime's successor. In round terms, it is about 2²ᵖ⁻¹, so its number of decimal digits is roughly 0.6 × p.

That means every gap between successful exponents is magnified. The exponent 31 gives a perfect number with 19 digits. An exponent in the millions gives a perfect number with over a million digits. Nobody writes such numbers out for the pleasure of it. Their short description, one exponent, says everything.

The successful exponents themselves become sparse. A random large number of the form 2ᵖ − 1 has only a small chance of being prime, though a better chance than a typical odd number of the same size, because its possible prime divisors are restricted. Any prime q dividing 2ᵖ − 1, with p an odd prime, must have the form 2kp + 1. For p = 11 the divisors 23 and 89 are 22 × 1 + 1 and 22 × 4 + 1. This restriction lets searchers eliminate many candidates cheaply before running a full test.

The test that makes large cases possible

The Lucas-Lehmer test applies to 2ᵖ − 1 when p is an odd prime. Start with 4. Repeatedly square the current value, subtract 2 and keep the remainder on division by 2ᵖ − 1. After p − 2 such steps, the number is prime exactly when the result is 0.

p = 5, so the modulus is 31
start:    4
step 1:   4² − 2 = 14
step 2:   14² − 2 = 194,  remainder 8
step 3:   8² − 2 = 62,    remainder 0
31 is prime

The work is a chain of squarings, which computers do very efficiently for this kind of modulus. The test says prime or composite with certainty, yet in the composite case it does not reveal any factor.

What remains unknown

Two basic questions are open as of the mid-2020s.

The first asks whether there are infinitely many even perfect numbers, which is the same as asking whether there are infinitely many Mersenne primes. Heuristic reasoning suggests yes, but there is no proof.

The second asks whether any odd perfect number exists. None has been found, and extensive theoretical and computer work shows that one would have to be enormous, with more than a thousand digits, and would need many prime factors meeting strict conditions. Restrictions narrow the search without proving that it is empty. See the odd perfect number question.

How the two proofs differ

It is worth pausing on the logic. Euclid's result says that a Mersenne prime is enough to produce a perfect number. Euler's says that, among even numbers, it is also necessary. Only together do they give an exact description, the kind of two-way statement discussed in proofs of "if and only if".

Neither proof says that any particular Mersenne prime exists. They convert one search into another, and the second search is easier to organize because it runs over exponents. Neither says anything about odd numbers, where Euler's opening step of splitting off a power of 2 has nothing to grip.

Try it yourself

Test whether p = 13 gives a perfect number. First, 2¹³ − 1 = 8191. Its square root is a little over 90, so checking the primes up to 89 settles primality, and none divides it. The perfect number is then 2¹² × 8191 = 4096 × 8191 = 33,550,336, the fifth on the list.

Now try p = 9. The exponent is not prime, so you already know the answer: 511 = 7 × 73, and no perfect number results.

Common questions

Is 1 a perfect number?

No. Its only divisor is itself, so the sum of its proper divisors is 0.

Can a power of 2 be perfect?

No. The proper divisors of 2ᵏ add to 2ᵏ − 1, which misses by exactly 1. No number whose proper divisors add to one more than itself has ever been found, either.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 59 articles in Number Theory →

Latest news on this topic