0
Check whether a number is perfect or not and return y or n accordingly
Use function
3 Réponses
+ 1
Please define a Perfect Number.
Saves me having to Google search
0
def pn_check(n):
if n== 1:
print(str(n) + " is NOT a prime number.")
a = 0
for i in range(1,n+1): # avoid ZeroDivisionError
if n % i == 0:
a += 1
if a > 2:
print(str(n)+ " is NOT a prime number.")
break
if a == 2:
print(str(n)+ " is a prime number!")
m = int(input())
pn_check(m)
0
My attempt