알고리즘왕/BOJ

[백준/4673/JAVA] 셀프 넘버

찌 ㅋ 2020. 3. 18. 00:24

public class Main {
	public static void main(String[] args) {
		boolean arr[] = new boolean[10001];
		for (int i = 1; i < 10001; i++) {
			int n = i;
			int d = i;
			while (d > 0) {
				n += d % 10;
				d /= 10;
			}
			if(n<10001) 
				arr[n] = true;
		}
		for (int i = 1; i < 10001; i++) {
			if (arr[i] == false)
				System.out.println(i);
		}
	}
}