A number is called perfect if it is equal to the sum of its factor other than the number itself. Example: 6= 1 + 2 + 3
import java.util.*;
class Perfect_no
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,s=0;
System.out.println("Enter the no");
n=sc.nextInt();
for(int j=1;j<n;j++)
{
if(n%j==0)
s=s+j;
}
if(n==s)
System.out.print("Perfect No ");
else
System.out.print("Not Perfect No ");
}
}
import java.util.*;
class Perfect_no
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,s=0;
System.out.println("Enter the no");
n=sc.nextInt();
for(int j=1;j<n;j++)
{
if(n%j==0)
s=s+j;
}
if(n==s)
System.out.print("Perfect No ");
else
System.out.print("Not Perfect No ");
}
}