forked from azure2103/program-wiz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerfect.java
More file actions
30 lines (29 loc) · 784 Bytes
/
Perfect.java
File metadata and controls
30 lines (29 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.*;
class Array_4
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int i,n;
int sum;
System.out.println("Enter the size of the array");
n=sc.nextInt();
System.out.println("Enter the numbers of the array");
int a[]=new int[n];
for (i=0;i<n;i++)
a[i]=sc.nextInt();
for (i=0;i<n;i++)
{
sum=0;
for (int j=1;j<a[i];j++)
{
if (a[i]%j==0)
sum=sum+j;
}
if (sum==a[i])
System.out.println(a[i]+" is a perfect number");
else
System.out.println(a[i]+" is not a perfect number");
}
}
}