- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprfNumber.java
More file actions
Latest commit
30 lines (24 loc) · 715 Bytes
/
Copy pathprfNumber.java
File metadata and controls
30 lines (24 loc) · 715 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
importjava.util.Scanner;
publicclassprfNumber {
publicstaticvoidmain(String[] args) {
intnum;
Scannerinp = newScanner(System.in);
System.out.println("Enter a num:");
num = inp.nextInt();
inttotal = 0;
for (inti = 1; i < num; i++) {
if(num == 1){
System.out.println("it isn't perfect number!");
break;
}
if(num % i == 0){
total += i;
}
}
if(total == num){
System.out.println("it is perfect num!");
}else
System.out.println("it is not perfect num!");
inp.close();
}
}