백준 4673 셀프 넘버
package Baekjoon;
public class B4673 {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean[] check = new boolean[10001];
for (int i = 1; i <= 10000; i++) {
int n = d(i);
if (n < 10001) {
check[n] = true;
}
}
for (int i = 1; i <= 10000; i++) {
if (!check[i]) {
System.out.println(i);
}
}
}
public static int d(int n) {
int sum = n;
while (n != 0) {
sum += n % 10;
n = n / 10;
}
return sum;
}
}