-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek2.java
More file actions
26 lines (25 loc) · 778 Bytes
/
week2.java
File metadata and controls
26 lines (25 loc) · 778 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.util.Scanner;
public class week2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of the Array :");
int n = sc.nextInt();
int[] a = new int[n];
int c;
for (int i = 0; i < n; i++) {
System.out.print("Enter " + (i + 1) + "th term :");
a[i] = sc.nextInt();
if (a[i] % 2 != 0) {
c = 0;
for (int j = 1; j <= a[i]; j++) {
if (a[i] % j == 0) {
c++;
}
}
if (c == 2) {
System.out.println(a[i] + " is Both Odd and Prime");
}
}
}
}
}