public class perfect { //记得修改文件名
public static void main(String[] args) {
// TODO Auto-generated method stub
int count=0,i=2,j=1,s1=0;
while(i<=100) //可以自行修改范围
{
j=1;
s1=0;
while(j<i)
{
if(i%j==0)
s1=s1+j;
j++;
}
if(s1==i)
{
count=count+1;
System.out.println(i+"是完全数!");
}
i++;
}
System.out.println("100以内有"+count+"个完全数!");
}
}