Self Numbers by emu101k

public class Test {
\x09public static void main(String[] a) {
\x09\x09new Test().t();
\x09}
\x09void t() {
\x09\x09int L = 3000;
\x09\x09int[] d=new int[L];
\x09\x09int[] o=new int[L];
\x09\x09for (int i=0;i<L;i++) {
\x09\x09\x09d[i]=i+1;
\x09\x09\x09o[i]=i+1;
\x09\x09}
\x09\x09for (int i:o) {
\x09\x09\x09int s=gS(i);
\x09\x09\x09if (i+s<=L) 
\x09\x09\x09\x09d[i+s-1]=0;\x09\x09\x09\x09
\x09\x09}
\x09\x09for(int i:d) 
\x09\x09\x09if (i!=0)
\x09\x09\x09\x09System.out.println(i);
\x09}
\x09int gS(int x) {
\x09\x09int s=0;
\x09\x09while(x>0) {
\x09\x09\x09s+=x%10;
\x09\x09\x09x/=10;       
\x09\x09}                       
\x09\x09return s;
\x09}
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page