完数是除本身之外的因子之和等于该数
package test;
public class wanshu {
public static void main(String[] args) {
int factor=0;
for(int i=1;i<=1000;i++) {
for(int j=1;j<=i/2;j++) {
if(i%j==0) {
factor+=j;
}
}
if(i==factor) {
System.out.println(i);
}
//重置factor!
factor=0;
}
}
}