为了账号安全,请及时绑定邮箱和手机立即绑定

为什么这个程序运行不出结果

这个程序是: 一个数如果恰好等于它的因子之和,这个数就称为“完数”,比如28=1+2+4+7+14。编写一个应用程序在屏幕上输出1000之内的完数。

程序运行是并没有报错,但是运行不出结果

public class test2 {


public static void main(String[] args) {

// TODO Auto-generated method stub

int s=0;

int n=0;

for(int i=1;i<=1000;i++) {

for(int j=1;j<i;j++) {

if(i%j==0)

s=s+j;

}

if(i==s)

System.out.print(""+s);

n++;

if(n<10)

continue;

System.out.println();

n=0;

}

System.out.println();

}


}


正在回答

1 回答

举报

0/150
提交
取消

为什么这个程序运行不出结果

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信