A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number, because 6 = 3 + 2 + 1, and the next is 28 = 14 + 7 + 4 + 2 + 1. There are four perfect numbers that are less than 10,000. Write a program to find these four numbers.
In number theory, a positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number, because 6 = 3 + 2 + 1, and the next is 28 = 14 + 7 + 4 + 2 + 1. There are only four perfect numbers that are less than 10,000. In this blog post, we will write a Python program to find these four numbers.
Python Program to Find Four perfect Numbers
Table of Contents [ Python Program Perfect Numbers ]
What are perfect numbers?
How to find perfect numbers?
Writing a program to find perfect numbers.
| Learn Python with “ Computer Courses — All in One “
What are perfect numbers?
A perfect number is a positive integer that is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is a perfect number because its divisors are 1, 2, and 3, and 1 + 2 + 3 = 6.
How to find perfect numbers?
To find perfect numbers, we need to check each positive integer to see if it is equal to the sum of its positive divisors. This can be done by iterating over all the integers from 1 to n and checking if each integer is a divisor of n. If it is, we add it to a running total. If the running total equals n at the end of the loop, then n is a perfect number.
https://play.google.com/store/apps/details?id=com.computerdictionary.mcqtutorial.computerbitspradip