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
36 lines (30 loc) · 728 Bytes
/
PrimeNumber.java
File metadata and controls
36 lines (30 loc) · 728 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
33
34
35
/* Nama : Chando Anggara Natanael Batubara
* Nim : 1301154390
* Kelas : IF 39-12
*/
import java.util.Scanner;
public class PrimeNumber {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Masukkan Sembarang Bilangan : ");
int angka = input.nextInt();
int x = 0;
for (int a = 1; a < angka; a++ )
{
if ((angka % a) == 0)
{
x++;
}
}
if ( x == 1)
{
System.out.print(" Bilangan tersebut merupakan BILANGAN PRIMA ");
}else
{
System.out.print("Bilangan tersebut BUKAN BILANGAN PRIMA ");
}
}
}