https://www.acmicpc.net/problem/9506
약수들의 합
import sys
while True :
n = int(input())
if n==-1 :break
sum =0
sumn = []
for i in range(1,n) :
if n%i == 0 :
sum+=i
sumn.append(i)
if sum != n : print(f"{n} is NOT perfect.",end=" ")
else :
print(f"{n} = 1",end=" ")
for k in range(len(sumn)) :
if k==0 : continue
else : print(f"+ {sumn[k]}", end=" ")
print()
'PROGRAMMING CODE > PYTHON' 카테고리의 다른 글
[BAEKJOON] No.2667 Python (0) | 2023.06.01 |
---|---|
[BAEKJOON] No.12865 Python (0) | 2023.03.23 |
[BAEKJOON] No.9610 Python (0) | 2023.03.22 |
[BAEKJOON] No.10988 Python (0) | 2023.03.22 |
[BAEKJOON] No. 2754 Python (0) | 2023.03.21 |