perfect number in 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))
perfect number in 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))
perfect number program in python
n = int(input("Enter any number: "))sum1 = 0for i in range(1, n):if(n % i == 0):sum1 = sum1 + iif (sum1 == n):print("The number is a Perfect number!")else:print("The number is not a Perfect number!")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us