-
-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathPerfectNum.java
More file actions
32 lines (30 loc) · 700 Bytes
/
PerfectNum.java
File metadata and controls
32 lines (30 loc) · 700 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
31
32
import java.util.Scanner;
public class PerfectNum
{
public static void main(String[] args)
{
int n, sum = 0;
Scanner s = new Scanner(System.in);
System.out.print("Enter any integer you want to check:");
n = s.nextInt();
for(int i = 1; i < n; i++)
{
if(n % i == 0)
{
sum = sum + i;
}
}
if(sum == n)
{
System.out.println("Given number is Perfect");
}
else
{
System.out.println("Given number is not Perfect");
}
}
int divisor(int x)
{
return x;
}
}