fork(1) download
  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String [] args){
  4. Scanner sc = new Scanner(System.in);
  5. int n = sc.nextInt();
  6.  
  7. for (int i = 1; i <= n; i++) {
  8. int v = sc.nextInt();
  9. int contador = 0;
  10.  
  11. for (int j = 1; j <= v; j++) {
  12. if (v % j == 0){
  13. contador++;
  14. if (contador == 3) {
  15. break;
  16. }
  17. }
  18. }
  19. if (contador == 2) {
  20. System.out.println("PRIME");
  21. } else {
  22. System.out.println("NOT PRIME");
  23. }
  24. }
  25. }
  26. }
Success #stdin #stdout 0.13s 321280KB
stdin
10
1
2
3
4
5
6
7
8
9
10
stdout
NOT PRIME
PRIME
PRIME
NOT PRIME
PRIME
NOT PRIME
PRIME
NOT PRIME
NOT PRIME
NOT PRIME