Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  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. int contador = 0;
  7.  
  8. for(int i = 1; i <= n; i++){
  9. int v = sc.nextInt();
  10.  
  11. for(int j = 1; j <= v; j++){
  12. if(v % j == 0){
  13. contador++;
  14. }
  15. }
  16. if(contador == 2){
  17. System.out.println("PRIME");
  18. }
  19. else{
  20. System.out.println("NOT PRIME");
  21. }
  22. }
  23. }
  24. }
  25.  
  26. import java.util.Scanner;
  27. public class Main {
  28. public static void main(String [] args){
  29. Scanner sc = new Scanner(System.in);
  30. int n = sc.nextInt();
  31.  
  32. for (int i = 1; i <= n; i++) {
  33. int v = sc.nextInt();
  34. int contador = 0;
  35.  
  36. for (int j = 1; j <= v; j++) {
  37. if (v % j == 0){
  38. contador++;
  39. if (contador == 3) {
  40. break;
  41. }
  42. }
  43. }
  44. if (contador == 2) {
  45. System.out.println("PRIME");
  46. } else {
  47. System.out.println("NOT PRIME");
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement