我昨天刚开始学习编码,并想尝试制作一个程序来帮助找到今天给定数字的所有完美数字。这些都行不通。Eclipse 上没有显示错误消息,所以我猜这些错误是合乎逻辑的(?)这是相关的代码,有人可以告诉我错误在哪里吗?
protected void actionPerformedProcessBtn(ActionEvent arg0) {
txtS.setText("");
int limit = Integer.parseInt(txtAmmount.getText()), a = 1, b = 1, c = 0;
while (a <= limit) {
while(a > b) {
if (a % b != 0) {
b++;
}
else {
c = c + b;
b++;
}
}
if (c == a)
txtS.append(a + "\n");
a++;
}
}
void ActionPerformedDoBtn(ActionEvent arg0) {
int c = 1, d, e;
txtS.setText("");
while (c <= 1000) {
d = 0;
e = 0;
while(d < c) {
if(c % d == 0)
e += d;
d++;
}
if (e == c)
txtS.append("Perf Num:" + c);
c++;
}
}