Question
- You've to check whether a given number is prime or not.
- Take a number "t" as input representing a count of input numbers to be tested.
- Take a number "n" as input "t" number of times.
- For each input value of n, print "prime" if the number is prime and "not prime" otherwise.
Input Format
A number t
A number n
A number n
.. t number of times
Output Format
prime
not prime
not prime
.. t number of timesConstraints
1 <= t <= 10000
2 <= n < 10^9
Sample Input
5
19
21
33
37
121
Sample Output
prime
not prime
not prime
prime
not prime
Program
import java.util.*;
  
  public class Main{
  
  public static void main(String[] args) {
      Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        for(int i=0;i<t;i++){
            int n = scn.nextInt();
            int count = 0;
        for(int div=2;div*div<=n; div++){ 
            if (n % div == 0){
                count++;
                break;
            }
        }
            if (count == 0){
                System.out.println("prime");
            }
            else{
                System.out.println("not prime");
            }
        }
   }
 }