A perfect number is defined to be one which is equal to the sum of its aliquot parts. The four perfect numbers 6, 28, 496 and 8128 seem to have been known from ancient times and there is no record of these discoveries:

6 = 1 + 2 + 3,

28 = 1 + 2 + 4 + 7 + 14,

496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248

8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064

28 = 1 + 2 + 4 + 7 + 14,

496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248

8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064

The first recorded mathematical result concerning perfect numbers which is known occurs in Euclidâ€™s Elements written around 300BC. He gave a condition on perfect numbers based on what later became known as Mersenne prime numbers.

One test iteration will find the perfect numbers below 500.