public static void main(String[] args) {
ArrayList<Integer> al = new ArrayList<>();
boolean flag = true;
for (int a = 100; a < 1000; a++) {
flag = true;
for (int b = 2; b < a; b++) {
if (a % b == 0) {
flag = false;
break;
}
}
if (flag) {
al.add(a);
}
}
Collections.reverse(al);
System.out.print(al);
}
|
|