-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.java
More file actions
29 lines (27 loc) · 771 Bytes
/
prime.java
File metadata and controls
29 lines (27 loc) · 771 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
import java.io.*;
import java.util.*;
public class Solution {
public static void check( int p){
int flag = 0;
for( int i = 2; i*i <= p; i++){
if ( p%i == 0){
flag = 1;
break;
}
}
if (flag == 0 )
System.out.println("Prime");
else
System.out.println("Not Prime");
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
int N;
Scanner scan = new Scanner(System.in);
N = scan.nextInt();
for ( int i = 0; i < N; i++){
int prime = scan.nextInt();
check(prime);
}
}
}