fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.Scanner;
  4. import java.io.IOException;
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws IOException {
  9.  
  10. isPrime liczba = new isPrime();
  11. Scanner input = new Scanner(System.in);
  12.  
  13. int n;
  14. int sum = 1;
  15. try {
  16. while (sum < 100000) {
  17. n = input.nextInt();
  18. liczba.TestPierwszosci(n);
  19. sum++;
  20. }
  21. } catch (Exception ex) {
  22. }
  23. }
  24.  
  25. static class isPrime {
  26. public void TestPierwszosci(int n) {
  27. int x = 2;
  28. int sum = 0;
  29. if (n != 1){
  30. mama: while (x < n) {
  31. if (sum == 0) {
  32. if (n % x == 0) {
  33. sum++;
  34. x++;
  35. } else x++;
  36. } else {
  37. System.out.println("NIE");
  38. break mama;
  39. }
  40. }
  41. if (sum == 0) System.out.println("TAK");
  42. } else System.out.println("NIE");
  43. }
  44. }
  45. }
Success #stdin #stdout 0.05s 711680KB
stdin
3
11
1
4
stdout
TAK
TAK
NIE
NIE