Perfect numbers are positive integers such that
(1)

where is the restricted divisor function (i.e., the sum of proper divisors of ), or equivalently
(2)

where is the divisor function (i.e., the sum of divisors of including itself). For example, the first few perfect numbers are 6, 28, 496, 8128, ... (OEIS A000396), since
(3)
 
(4)
 
(5)

etc.
The th perfect number is implemented in the Wolfram Language as PerfectNumber[n] and checking to see if is a perfect number as PerfectNumberQ[k].
The first few perfect numbers are summarized in the following table together with their corresponding indices (see below).
1  2  6 
2  3  28 
3  5  496 
4  7  8128 
5  13  33550336 
6  17  8589869056 
7  19  137438691328 
8  31  2305843008139952128 
Perfect numbers were deemed to have important numerological properties by the ancients, and were extensively studied by the Greeks, including Euclid.
Perfect numbers are also intimately connected with a class of numbers known as Mersenne primes, which are prime numbers of the form . This can be demonstrated by considering a perfect number of the form where is prime. By definition of a perfect number ,
(6)

Now note that there are special forms for the divisor function
(7)

for a prime, and
(8)

for . Combining these with the additional identity
(9)

where is the prime factorization of , gives
(10)
 
(11)
 
(12)

But , so
(13)

Solving for then gives
(14)

Therefore, if is to be a perfect number, must be of the form . Defining as a prime number of the form , it then follows that
(15)

is a perfect number, as stated in Proposition IX.36 of Euclid's Elements (Dickson 2005, p. 3; Dunham 1990).
While many of Euclid's successors implicitly assumed that all perfect numbers were of the form (15) (Dickson 2005, pp. 333), the precise statement that all even perfect numbers are of this form was first considered in a 1638 letter from Descartes to Mersenne (Dickson 2005, p. 12). Proof or disproof that Euclid's construction gives all possible even perfect numbers was proposed to Fermat in a 1658 letter from Frans van Schooten (Dickson 2005, p. 14). In a posthumous 1849 paper, Euler provided the first proof that Euclid's construction gives all possible even perfect numbers (Dickson 2005, p. 19).
It is not known if any odd perfect numbers exist, although numbers up to (Ochem and Rao 2012) have been checked without success.
All even perfect numbers are of the form
(16)

where is a triangular number
(17)

such that (Eaton 1995, 1996). In addition, all even perfect numbers are hexagonal numbers, so it follows that even perfect numbers are always the sum of consecutive positive integers starting at 1, for example,
(18)
 
(19)
 
(20)

(Singh 1997), where 3, 7, 31, ... (OEIS A000668) are simply the Mersenne primes. In addition, every even perfect number is of the form , so they can be generated using the identity
(21)

It is known that all even perfect numbers (except 6) end in 16, 28, 36, 56, 76, or 96 (Lucas 1891) and have digital root 1. In particular, the last digits of the first few perfect numbers are 6, 8, 6, 8, 6, 6, 8, 8, 6, 6, 8, 8, 6, 8, 8, ... (OEIS A094540), where the region between the 38th and 41st terms has been incompletely searched as of June 2004.
The sum of reciprocals of all the divisors of a perfect number is 2, since
(22)

(23)

(24)

If , is said to be an abundant number. If , is said to be a deficient number. And if for a positive integer , is said to be a multiperfect number of order .
The only even perfect number of the form is 28 (Makowski 1962).
Ruiz has shown that is a perfect number iff
(25)
