I'm currently making a program that list all the perfect numbers from 1-1000. and list also its factors.
heres my code.
public class perfect
{
public static void main(String[]args)
{
int sum=0;
int x=0;
for(int num=1;num<1000;num++)
{
for(int factor=1;factor<num;factor++){
x=num%factor;
if(x==0)
sum=sum+factor;}
if(sum==num){
System.out.print(num);
System.out.print("The factors are ");
for(int factor=1;factor<num;factor++)
{
x=num%factor;
if(x==0)
System.out.print(factor);
}
}
}
}
}
when i compiled it there is no error but it doesn't display anything...
could someone help me...