-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_235Array.java
More file actions
27 lines (26 loc) · 1010 Bytes
/
Copy path_235Array.java
File metadata and controls
27 lines (26 loc) · 1010 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
27
public class _235Array {
public static void main (String[] args) {
System.out.println(is235Array(new int[] {2, 3, 5, 7, 11}));
System.out.println(is235Array(new int[] {2, 3, 6, 7, 11}));
System.out.println(is235Array(new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}));
System.out.println(is235Array(new int[] {2, 4, 8, 16, 32}));
System.out.println(is235Array(new int[] {3, 9, 27, 7, 1, 1, 1, 1, 1}));
System.out.println(is235Array(new int[] {7, 11, 77, 49}));
System.out.println(is235Array(new int[] {2}));
System.out.println(is235Array(new int[] {}));
System.out.println(is235Array(new int[] {7, 2, 7, 2, 7, 2, 7, 2, 3, 7, 7}));
}
static int is235Array (int[] a) {
int count = 0;
for (int i = 0; i < a.length; i++) {
if (a[i] % 2 == 0) count++;
if (a[i] % 3 == 0) count++;
if (a[i] % 5 == 0) count++;
if (a[i] % 2 != 0 && a[i] % 3 != 0 && a[i] % 5 != 0) count++;
}
if (count == a.length)
return 1;
else
return 0;
}
}