-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprime.java
More file actions
23 lines (22 loc) · 757 Bytes
/
Copy pathprime.java
File metadata and controls
23 lines (22 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class prime {
public static void main(String args[]){
int a , b=0;
Scanner obj = new Scanner(System.in);
System.out.println("Enter a number :");
a = obj.nextInt();
obj.close();
if (a==0 || a==1)
System.out.println("Neither prime nor composite");
for (int i=2;i<=a/2;i++){
if (a%i==0){
b = 1;
break;
}
}
if (b==1)
System.out.println("It is Not Prime");
else
System.out.println("It is Prime");
}
}