-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayPrime.java
More file actions
26 lines (25 loc) · 887 Bytes
/
ArrayPrime.java
File metadata and controls
26 lines (25 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.io.*;
public class ArrayPrime {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF ELEMENTS");
int n = Integer.parseInt(br.readLine());
int arr[] = new int[n];
System.out.println("ENTER THE INTEGERS");
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(br.readLine());
}
int count = 0;
for (int j = 0; j < n; j++) {
for (int k = 1; k <= arr[j]; k++) {
if (arr[j] % k == 0)
count++;
}
if (count == 2)
System.out.println("PRIME NUMBER=" + arr[j]);
else
System.out.println("NOT-PRIME NUMBER=" + arr[j]);
count = 0;
}
}
}