Have you ever thought if a number could be perfectly balanced, i.e., the number is equal to the sum of its own divisors except itself? That special kind of number is called a Perfect Number, and it is one of the coolest ideas in math. They are rare and only a few of them have ever been found. Perfect Numbers are also used in many real-life applications.
In this article, we will learn about Perfect Numbers in detail.
Table of Contents:
What is a Perfect Number?
A Perfect Number is a kind of whole number in mathematics that is exactly equal to the sum of all its proper divisors, i.e., all the numbers that divide it perfectly, excluding the number itself.
In short, we can say that a perfect number is a positive integer that is equal to the sum of its proper divisors, excluding itself.
For example,
Take the number 6. The divisors of 6 are 1, 2, and 3. Now, adding all the proper divisors of 6, we get
1 + 2 + 3 = 6
Master DSA Today - Accelerate Your Future
Enroll Now and Transform Your Future
What are the First 4 Perfect Numbers?
The first 4 perfect numbers are:
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 + ... + 4064
These numbers grow very fast and are rare; all known perfect numbers so far are even and follow a special formula.
Which is the Smallest Perfect Number?
From the above list of the first 4 perfect numbers, we see that 6 is the smallest perfect number.
History of Perfect Numbers
The idea of perfect numbers was found thousands of years ago, in ancient Greece.
- Pythagoras, around the 6th century BCE, a famous Greek mathematician, and his followers found that the numbers had deep meaning and harmony. They considered the perfect numbers to be divine or special.
- Later, Euclid in around 300 BCE, one of the most famous mathematicians in history, gave a mathematical formula to find perfect numbers, and this idea is still used today.
Mersenne Prime
Marin Mersenne, a French mathematician from the 17th century, studied about the numbers in detail, i.e., a Mersenne prime is a special kind of prime number that has a very specific shape which can be written in the form of,
M = 2ⁿ − 1
where,
- n is a whole number (a positive integer)
- M is a prime number
Note: Every number in the form 2ⁿ − 1 is not a prime number. M is only prime if n is prime, but even then, it is not always true.
For example, let’s take n = 4,
2⁴ − 1 = 16 − 1 = 15
15 is not a prime number, because it is divisible by 3 and 5 also. Hence, only some values of n give Mersenne primes.
Mersenne primes are connected to the perfect numbers. Because Euclid’s Perfect Number Theorem only works when 2ⁿ − 1 is a Mersenne prime
Euclid’s Perfect Number Theorem
The great Greek mathematician Euclid, called the father of geometry around 300 BCE, made a theorem that still helps our understanding of perfect numbers today. Euclid found a mathematical formula that can be used to generate certain perfect numbers. But his method only produces an even perfect number, and only under a special condition.
If 2ⁿ − 1 is a prime number (called a Mersenne prime), then the number 2ⁿ⁻¹ (2ⁿ − 1) is a perfect number.
Now, let us learn how to calculate a perfect number using Euclid’s theorem.
1. Pick any number n
2. Then, check whether the number 2ⁿ − 1 is a prime number or not;
3. If it is, then use the formula, 2ⁿ⁻¹ × (2ⁿ − 1)
4. The result will be a perfect number.
Note: If the number is not prime, then you cannot use the formula.
For example, let the number be 2. Then,
2² − 1 = 3
3 is a prime number. Now, moving forward as per the formula.
2¹ × (2² − 1) = 2 × 3 = 6
So, 6 is a perfect number.
Get 100% Hike!
Master Most in Demand Skills Now!
Method to Check for a Perfect Number By Checking Proper Divisors
This method is good for small numbers and works well if you are checking whether a specific number is perfect.
- Write down all the proper divisors of the number, excluding the number itself.
- Add all the numbers up to all those divisors. If the sum of all the divisors is equal to the original number, then it is a perfect number.
For example, let’s check for the number 28
All proper divisors of 28 are 1, 2, 4, 7, and 14. And sum of all the divisors of 28 is: 1 + 2 + 4 + 7 + 14 = 28
As the sum of all the divisors of 28 is equal to the original number, hence, 28 is perfect.
Note: This method is best for only small numbers, like under 10,000
Perfect Number Table
Now, let us discuss some commonly known perfect numbers.
Perfect Numbers List from 1 to 100
There are mainly 2 perfect numbers present between 1 and 100.
Perfect Number |
Proper Divisors |
Sum of Divisors |
6 |
1, 2, 3 |
1 + 2 + 3 = 6 |
28 |
1, 2, 4, 7, 14 |
1 + 2 + 4 + 7 + 14 = 28 |
List of 52 Perfect Numbers
Below is the list of all 52 perfect numbers:
S. No. |
Perfect Number (Truncated) |
Number of Digits |
1 | 6 | 1 |
2 | 28 | 2 |
3 | 496 | 3 |
4 | 8128 | 4 |
5 | 33,550,336 | 8 |
6 | 8,589,869,056 | 10 |
7 | 137,438,691,328 | 12 |
8 | 230,584…952,128 | 19 |
9 | 265,845…842,176 | 37 |
10 | 191,561…169,216 | 54 |
11 | 131,640…728,128 | 65 |
12 | 144,740…152,128 | 77 |
13 | 235,627…646,976 | 314 |
14 | 141,053…328,128 | 366 |
15 | 541,625…291,328 | 770 |
16 | 108,925…782,528 | 1,327 |
17 | 994,970…915,776 | 1,373 |
18 | 335,708…525,056 | 1,937 |
19 | 182,017…377,536 | 2,561 |
20 | 407,672…534,528 | 2,663 |
21 | 114,347…577,216 | 5,834 |
22 | 598,885…496,576 | 5,985 |
23 | 395,961…086,336 | 6,751 |
24 | 931,144…942,656 | 12,003 |
25 | 100,656…605,376 | 13,066 |
26 | 811,537…666,816 | 13,973 |
27 | 365,093…827,456 | 26,790 |
28 | 144,145…406,528 | 51,924 |
29 | 136,204…862,528 | 66,530 |
30 | 131,451…550,016 | 79,502 |
31 | 278,327…880,128 | 130,100 |
32 | 151,616…731,328 | 455,663 |
33 | 838,488…167,936 | 517,430 |
34 | 849,732…704,128 | 757,263 |
35 | 331,882…375,616 | 841,842 |
36 | 194,276…462,976 | 1,791,864 |
37 | 811,686…457,856 | 1,819,050 |
38 | 955,176…572,736 | 4,197,919 |
39 | 427,764…021,056 | 8,107,892 |
40 | 793,508…896,128 | 12,640,858 |
41 | 448,233…950,528 | 14,471,465 |
42 | 746,209…088,128 | 15,632,458 |
43 | 497,437…704,256 | 18,304,103 |
44 | 775,946…120,256 | 19,616,714 |
45 | 204,534…480,128 | 22,370,543 |
46 | 144,285…253,376 | 25,674,127 |
47 | 500,767…378,816 | 25,956,377 |
48 | 169,296…130,176 | 34,850,340 |
49 | 451,129…315,776 | 44,677,235 |
50 | 109,200…301,056 | 46,498,850 |
51 | 110,847…207,936 | 49,724,095 |
52 | 388,692…008,576 | 82,048,640 |
Why only 52 perfect numbers?
Each even perfect number comes from a Mersenne prime, and they are very rare, so far, only 52 of them have been found. That’s why we know only 52 even perfect numbers, but there can be more perfect numbers.
Perfect Numbers Programs in C
The programs below check whether a given number is a perfect number or not by finding its proper divisors that divide it exactly, excluding the number itself. It adds these divisors together, and if their sum is equal to the original number, it is said to be perfect. It uses a for loop and % to check for divisibility. If the sum of the divisors matches the number, it prints that the number is a perfect number; otherwise, it prints that it is not.
Program to Find Perfect Number in C++, Java, and Python
1. C++ Program to Check a Perfect Number
Below is the C++ program to check for a perfect number:
Output:
2. Java Program to Check a Perfect Number
Below is the Java program to check for a perfect number:
Output:
3. Python Program to Check a Perfect Number
Below is the Python program to check for a perfect number:
Output:
Perfect Numbers vs Perfect Squares
A perfect number is a positive integer that is equal to the sum of its proper divisors and excluding the number itself. Perfect numbers are very rare and grow quickly. Only a few are known, such as 6, 28, 496, and 8128. They are connected to number theory and special prime numbers called Mersenne primes, and also, all known perfect numbers till now are even. For example, 28 is a perfect number because its proper divisors are 1, 2, 4, 7, and 14, and their sum is 28.
On the other hand, a perfect square is a number that results from multiplying an integer by itself. Perfect squares can be either odd or even, and they are closely tied to multiplication and geometry. For example, 16 is a perfect square, which can be written as 4 × 4.
Feature |
Perfect Number |
Perfect Square |
Meaning |
Sum of factors |
Number × itself |
How common |
Rare |
Very common |
Used in |
Math and primes |
Shapes and counting |
Example |
28 |
16 |
Applications of Perfect Numbers
1. Mathematics: Perfect numbers are an important part of number theory, as they help us to understand how the numbers are made up of their factors. Mathematicians have studied them for thousands of years because they have interesting properties and patterns. They are also connected to special prime numbers called Mersenne primes.
2. Cryptography: Mersenne prime numbers are used in computer security to protect the information. They are not used directly, but the math behind them helps in finding large prime numbers, which helps in keeping data safe online.
3. Programming: Many perfect number problems are often given in coding interviews, which help beginners to practice using loops, conditions, and efficient algorithms. For example, writing a program to check if a number is perfect or not teaches a person how to deal with the divisors.
4. Digital Signal Processing: In signal processing, perfect numbers have applications, like perfect numbers have been studied about buffer sizes or block alignment in DSP, where symmetrical patterns are main.
Conclusion
Perfect numbers are the numbers that are equal to the sum of their proper divisors, excluding themselves. They are rare, and all the known ones so far are even. These numbers come from Mersenne primes, and no one has ever found an odd perfect number. Perfect numbers are interesting not just in math but also in areas like coding and computer science. They help us learn more about how numbers work and are fun to explore.
If you want to learn more about this topic, you can refer to our DSA Course.
What is a Perfect Number – FAQs
Q1. What are the first 5 perfect numbers?
The first 5 perfect numbers are 6, 28, 496, 8128, and 33550336.
Q2. Is 36 a perfect number?
No, 36 is not a perfect number; it is a perfect square.
Q3. Which number is perfect?
A perfect number is a positive integer whose the sum is equal to its positive proper divisors, excluding the number itself
Q4. Who invented perfect numbers?
Euclid invented the basics of perfect numbers over 2,000 years ago, and he knew that the first four perfect numbers were 6, 28, 496, and 8,128.
Q5. What is the perfect number trick?
The perfect number trick is, find all the proper divisors of the number, add them together, and then if the sum is equal to the original number, then it is a perfect number