In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 has divisors 1, 2 and 3 (excluding itself), and 1 + 2 + 3 = 6, so 6 is a perfect number.
The sum of divisors of a number, excluding the number itself, is called its aliquot sum, so a perfect number is one that is equal to its aliquot sum. Equivalently, a perfect number is a number that is half the sum of all of its positive divisors including itself; in symbols, where is the sum-of-divisors function. For instance, 28 is perfect as 1 + 2 + 4 + 7 + 14 = 28.
This definition is ancient, appearing as early as Euclid's Elements (VII.22) where it is called τέλειος ἀριθμός (perfect, ideal, or complete number). Euclid also proved a formation rule (IX.36) whereby is an even perfect number whenever is a prime of the form for positive integer —what is now called a Mersenne prime. Two millennia later, Leonhard Euler proved that all even perfect numbers are of this form. This is known as the Euclid–Euler theorem.
It is not known whether there are any odd perfect numbers, nor whether infinitely many perfect numbers exist. The first few perfect numbers are 6, 28, 496 and 8128 .
In about 300 BC Euclid showed that if 2p − 1 is prime then 2p−1(2p − 1) is perfect.
The first four perfect numbers were the only ones known to early Greek mathematics, and the mathematician Nicomachus noted 8128 as early as around AD 100. In modern language, Nicomachus states without proof that every perfect number is of the form where is prime. He seems to be unaware that n itself has to be prime. He also says (wrongly) that the perfect numbers end in 6 or 8 alternately. (The first 5 perfect numbers end with digits 6, 8, 6, 8, 6; but the sixth also ends in 6.) Philo of Alexandria in his first-century book "On the creation" mentions perfect numbers, claiming that the world was created in 6 days and the moon orbits in 28 days because 6 and 28 are perfect.