forked from rahulsain/Hackerrank_30daysOFcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday 25.java
62 lines (48 loc) · 951 Bytes
/
day 25.java
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
56
57
58
59
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void isPrime(int a)
{
int i;
if(a>1000000000)
{ double c=0;
for(i=1;i<=a/4;i++)
{
if(a%i==0)
c++;
if(c>2) break;
}
if(c==1)
System.out.println("Prime");
else
System.out.println("Not prime");
return;
}
double c=0;
for(i=1;i<=a;i++)
{
if(a%i==0)
c++;
if(c>2) break;
}
if(c==2)
System.out.println("Prime");
else
System.out.println("Not prime");
}
public static void main(String[] args) {
/* Enter your code here. */
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int A[]=new int[n];
for(int i=0;i<n;i++)
{
A[i]=sc.nextInt();
}
for(int i=0;i<n;i++)
Solution.isPrime(A[i]);
}
}