forked from OOP-ADF/Task_1
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimeNumber.java
More file actions
Latest commit
25 lines (20 loc) · 555 Bytes
/
Copy pathPrimeNumber.java
File metadata and controls
25 lines (20 loc) · 555 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
importjava.util.Scanner;
publicclassCobaPrime {
publicstaticvoidmain(String[] args) {
intx, y;
intz = 0;
Scannercin = newScanner(System.in);
System.out.print("Inputkan Angka : ");
x = cin.nextInt();
for (y = 1; y <= x; y++) {
if (x % y == 0) {
z = z + 1;
}
}
if (z == 2) {
System.out.println(+x + " Adalah Bilangan Prima");
} else {
System.out.println(+x + " Bukan Bilangan Prima")
}
}
}