{"id":8186,"date":"2021-06-07T18:20:46","date_gmt":"2021-06-07T12:50:46","guid":{"rendered":"https:\/\/python-programs.com\/?p=8186"},"modified":"2021-11-22T18:38:38","modified_gmt":"2021-11-22T13:08:38","slug":"python-program-to-check-whether-the-given-number-is-perfect-number-or-not","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-whether-the-given-number-is-perfect-number-or-not\/","title":{"rendered":"Python Program to Check Whether the given Number is Perfect Number or Not"},"content":{"rendered":"

Perfect Number in python:<\/strong><\/p>\n

If the sum of a number’s appropriate divisors (excluding the number itself) equals the number, the number is said to be the perfect number.<\/p>\n

Consider the following example: appropriate divisors of 6 are 1, 2, 3. Because the sum of these divisors equals 6 (1+2+3=6), 6 is considered a perfect number. When we consider another number, such as 12, the proper divisors of 12 are 1, 2, 3, 4, and 6. Now, because the sum of these divisors does not equal 12, 12 is not a perfect number.<\/p>\n

Python programming is simpler and more enjoyable than programming in other languages due to its simplified syntax and superior readability. Now that we understand the concept of a perfect number, let’s construct a Python program to determine whether or not a number is a perfect number. Let’s write some Python code to see if the given user input is a perfect number or not, and have some fun with Python coding.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number = 6<\/pre>\n

Output:<\/strong><\/p>\n

The given number 6 is perfect number<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number = 179<\/pre>\n

Output:<\/strong><\/p>\n

The given number 179 is not a perfect number<\/pre>\n

Python Program to Check Whether the given Number is Perfect Number or Not<\/h2>\n

There are several ways to check whether the given number is perfect number or not some of them are:<\/p>\n