Python program to find whether it is perfect number or not

preview_player
Показать описание
Question 12- write a program to accept a number and find out whether it is perfect number or not.

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.

Class 11 - First Python Assignment solution
#python #pythonprogram

👉Source code is given in the comment box💖💖

Guys if you also want that i solve your question then comment me.

Asked by
Rashmi Singh
Рекомендации по теме
Комментарии
Автор

#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

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)

parvatcomputertechnology
join shbcf.ru