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
34 lines (28 loc) · 764 Bytes
/
PrimeNumber.java
File metadata and controls
34 lines (28 loc) · 764 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
/*
* Lailis Sa'adah
*1301154502
*If39-12
*/
package pkg1301154502_lailissaadah_if3912_task1;
/**
*
* @author user
*/
import java.util.Scanner;
public class PrimeNumber {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
System.out.print(" masukkan bilangan : ");
int bilangan = input.nextInt();
boolean prima = true;
for (int i=2; i<bilangan; i++){
if ((bilangan % i) == 0){
prima = false; break;
}
}
if (prima)
System.out.println(bilangan + " adalah bilangan Prima ");
else
System.out.println(bilangan + " adalah bukan bilangan prima ");
}
}