programming-examples/python/Function/Python function to check whether a number is perfect or not.py
2019-11-15 12:59:38 +01:00

7 lines
169 B
Python

def perfect_number(n):
sum = 0
for x in range(1, n):
if n % x == 0:
sum += x
return sum == n
print(perfect_number(6))