When I run eclipse the result it shows me are
0
6
28
240
496
1344
8128
The expected results are:
6
28
496
8128
Why does my code print 0, 240, and 1344?
import acm.program.*;
public class Chapter5Exercise11isPerfect extends ConsoleProgram{
public void run (){
for (int i = 1; i <= 9999; i++){
int k = 0;
for (int s = 1; s <=i/2; s++){
if (i%s ==0){
k=k+s;
}
}
if (k%i==0){
println (k);
}
}
}
}