Computer Science, asked by nishitsomani, 9 months ago

write a program to check number is perfect number or not​

Answers

Answered by arifanadeem24
5

Answer:

hope it helps

mark as brainlist

follow me.........

def is_perfect_number(n):

   sum = 1

   i = 2

   while i * i <= n:

       if n % i == 0:

           sum = sum + i + n/i

           i += 1

           return (True if sum == n and n!=1 else False)

       num = int(input(“Enter a number : “))

       if(is_perfect_number(num)):

           print(num,”is a perfect number”)

           else:

               print(num,”is not a perfect number”)

Answered by Anonymous
5

Answer:

its a python program

Explanation:

#program to find whether the number given is perfect or not

n=int(input("enter a number"))

sum=0

for i in range (1,n):

   if n%i==0:

       sum+=i

if sum==n:

   print(n,"is a perfect number")

else:

   print(n,"is not a perfect number")

#hope it helps you

please mark brainliest

Similar questions