A number whose sum of factors (excluding the number itself) is equal to the number is called a perfect number. In other words, if the sum of positive divisors (excluding the number itself) of a number equals the number itself is called a perfect number.

Example program:
public class Perfect_number
{
public static void main(String[] args)
{
int num=28;
int div=1;
int total = 0;
while(div<num)
{
if(num%div==0)
{
System.out.println(div);
total = total+div;
}
div++;
}
System.out.println(total);
if(num==total)
{
System.out.println("Perfect");
}
}
}
output:
