package day;
public class prastic1 {
public static void main(String[] args) {
int count =0;
for(int i =1; i <=1000;i++){
for (int j =1; j< i;j++){
if (i %j==0){
count += j;
}
}
if (i==count){
System.out.println(i);
}
//重置count
count =0;
}
}
}
一个数如果恰好等于它的因子之和,这个数就称为“完数“。例如6=1+2+3。编程 找出1000以内的所有完数。(因子:除去这个数本身的其它约数
最新推荐文章于 2023-11-27 20:30:06 发布