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