Write a program in Python to accept a number and print the sum of sum of perfect
numbers between 10 and 1000.
i need it quick if possible......6 mins max?
Answers
Explanation:
Python Program to find Perfect Number
How to write a Python program to find Perfect Number using For Loop, While Loop, and Functions.
Python Perfect Number
Any number can be perfect number in Python, if the sum of its positive divisors excluding the number itself is equal to that number.
For example, 6 is a perfect number in Python because 6 is divisible by 1, 2, 3 and 6. So, the sum of these values are: 1+2+3 = 6 (Remember, we have to exclude the number itself. That’s why we haven’t added 6 here). Some of the perfect numbers are 6, 28, 496, 8128 and 33550336 so on.
Python Program to find Perfect Number using For loop
This Python program for Perfect Number allows the user to enter any number. Using this number it will calculate whether the number is Perfect number or not using the Python For Loop.
# Python Program to find Perfect Number using For loop
Number = int(input(" Please Enter any Number: "))
Sum = 0
for i in range(1, Number):
if(Number % i == 0):
Sum = Sum + i
if (Sum == Number):
print(" %d is a Perfect Number" %Number)
else:
print(" %d is not a Perfect Number" %Numbe