A perfect integer is a number which is equal to the sum of all its factors.
e.g. 28 is a perfect integer as it is the sum of all its factors -
1 + 2 + 4 + 7 + 14
Write a program to display perfect integers from 1 to 1000.
Answers
Answered by
12
- 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" %Number)
Similar questions