-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprimeOrNot.java
More file actions
37 lines (33 loc) · 865 Bytes
/
primeOrNot.java
File metadata and controls
37 lines (33 loc) · 865 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
36
37
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nazimacadviw;
import java.util.*;
/**
*
* @author Nazim
*/
public class primeOrNot {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int i,m=0,flag=0;
int n;
System.out.println("Enter Number:");
n=sc.nextInt();
m=n/2;
if(n==0||n==1){
System.out.println(n+" is not prime number");
}else{
for(i=2;i<=m;i++){
if(n%i==0){
System.out.println(n+" is not prime number");
flag=1;
break;
}
}
if(flag==0) { System.out.println(n+" is prime number"); }
}//end of else
}
}