-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 25
55 lines (49 loc) · 1.21 KB
/
Day 25
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
46
47
48
49
50
51
52
53
54
55
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCases=scan.nextInt();
long mod =2*10^9L;
while(testCases>=1 && testCases<=30)
{
int n=scan.nextInt();
if(n>=1)
{
findPrimeNumber(n);
}
else
{
System.out.println("Wrong input");
}
testCases--;
}
}
static void findPrimeNumber(int n){
if(n<=1)
{
System.out.println("Not prime");
}
else if (n==2)
{
System.out.println("Prime");
}
else
{
int count=0;
for(int i=2;i<=Math.sqrt(n);i++)
{
if(n%i==0)
{
count=1;
System.out.println("Not prime");
break;
}
}
if(count==0)
{
System.out.println("Prime");
}
}
}
}