반응형
SMALL
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
if(n == -1){
break;
}
int sum = 0;
StringBuilder str = new StringBuilder();
for(int i = 1 ; i < n ; i++){
if(n%i == 0){
sum+=i;
str.append(i).append(" + "); //1 + ~~
}
}
if(sum==n){
str.setLength(str.length() - 3);
System.out.println(n + " = " + str);
}else{
System.out.println(n + " is NOT perfect.");
}
}
}
}
반응형
LIST
'JAVA > JAVA baekjoon' 카테고리의 다른 글
9063번 대지 (0) | 2023.08.29 |
---|---|
1978번 소수 찾기 (0) | 2023.08.28 |
2501번 약수구하기 (0) | 2023.08.28 |
5086번 배수와 약수 (0) | 2023.08.28 |
2869 달팽이 (0) | 2023.08.28 |