search number is complete or no python 1

search number is complete or no python

number=int(input("enter the number :"))
s=0
for i in range (1,number):
    if(number%i==0):
        s+=i
if(s==number):
    print("the number is true")    
else :
    print("the number is not true")

Here is what the above code is Doing:
1. We are taking a number from the user.
2. We are checking if the number is divisible by any number between 1 and the number itself.
3. If the number is divisible by any number between 1 and the number itself, we are adding that number to the sum.
4. If the sum of all the numbers is equal to the number itself, then the number is a perfect number.

Similar Posts