To print whether the number is perfect or not

18/03/2013 08:27

 

public class perfectnumbers
{
public static void main(String args[])
{
int a=6;
int sum=0;
for(int i=1;i<a;i++)
{
if(a%i==0)
{
sum=sum+i;
}
}
if(sum==a)
System.out.println("the number is perfect");
else
System.out.println("the number is imperfect");
}
}