-
Notifications
You must be signed in to change notification settings - Fork 0
/
perfect_num.py
41 lines (24 loc) · 933 Bytes
/
perfect_num.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
print("|-------------------------EXPERIMENT NO.21-----------------------------|")
print("| FINIDING IF THE NUMBER IS PERFECT OR NOT |")
print("|----------------------------------------------------------------------|")
total=0
num=int(input(" Enter a number : "))
print()
for factor in range(1,num+1):
if num%factor==0:
if factor==1:
print(" ",factor,end="")
total+=factor
elif factor>1 and factor<num:
print(" + ",factor,end="")
total+=factor
else:
print(" =",factor)
else:
continue
print("-"*72)
if total==num:
print("| ",num," is a perfect number |")
else:
print("| ",num," is not a perfect number |")
print("-"*72)