-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay 26.java
More file actions
45 lines (43 loc) · 1.02 KB
/
Day 26.java
File metadata and controls
45 lines (43 loc) · 1.02 KB
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
38
39
40
41
42
43
44
45
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
while(n-- > 0)
{
int a=sc.nextInt();
if(a==1)
{
System.out.println("Not prime");
}
else if(a==2)
{
System.out.println("Prime");
}
else
{
int c=0;
for(int i=2;i<=(int)Math.sqrt(a);i++)
{
if(a%i==0)
{
c++;
break;
}
}
if(c==0)
{
System.out.println("Prime");
}
else
{
System.out.println("Not prime");
}
}
}
}
}