-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCheckPrimeNumber.java
More file actions
27 lines (27 loc) · 857 Bytes
/
Copy pathCheckPrimeNumber.java
File metadata and controls
27 lines (27 loc) · 857 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
package Exercise;
import java.util.Scanner;
public class CheckPrimeNumber {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int NumX,LimitNum=2;
boolean PrimeNum=true,T=true,F=false;
System.out.println("This is PRIME NUMBER or not?");
System.out.print("Enter Integer: ");
NumX=input.nextInt();
if(NumX>1){
while(NumX>LimitNum){
if(NumX%LimitNum==0){
PrimeNum=false;break;
}
LimitNum++;
}
if(PrimeNum&&T){
System.out.println(NumX+" is Prime Number.");
}else{
System.out.println(NumX+" is not Prime Number.");
}
}else{
System.out.println(NumX+" is not Prime Number.");
}
}
}