public static void main(String[] args) throws IOException { StreamTokenizer input = new StreamTokenizer(new InputStreamReader(System.in)); input.nextToken(); int n = (int) input.nval; boolean[] tab = new boolean[n];
for(int i = 0; i < n; i++) { input.nextToken(); tab[i] = prim((int) input.nval); }
for(int i = 0; i < n; i++) if(tab[i]) System.out.println("TAK"); else System.out.println("NIE"); }
public static boolean prim(int liczba) { if(liczba < 2) return false; for(int i = 2; i * i <= liczba; i++) if( (liczba % i ) == 0) return false; return true; } }
Wyszukiwarka