public class Main {
public static void main(String[] args) {
boolean check[] = new boolean[10001];
for(int i = 1; i<check.length; i++) {
int n = selfNumber(i);
if(n<10001)
check[n] = true;
}
StringBuilder sb = new StringBuilder();
for(int i = 1; i<check.length; i++) {
if(check[i]==false) {
sb.append(i).append("\n");
}
}
System.out.println(sb);
}
public static int selfNumber(int i) {
int sum = i;
while(i!=0) {
sum = sum +(i%10);
i/=10;
}
return sum;
}
}
'코딩테스트 문제풀이' 카테고리의 다른 글
프로그래머스 (문자열 내림차순으로 배치하기) (0) | 2021.10.10 |
---|---|
백준 14681번 (사분면 고르기) (0) | 2021.10.10 |
프로그래머스 (두 개 뽑아서 더하기) (0) | 2021.09.30 |
프로그래머스 (예산) (0) | 2021.09.29 |
프로그래머스 (3진법 뒤집기) (0) | 2021.09.28 |