0~20之间素数。
public class wf1 {
public static void main(String[] args) {
for (int i = 1; i <= 20; i++) {
int j = 2;
while (i % j != 0) {
j++;
}
if (j == i) {
System.out.println(i);
}
}
}
}
素数就是质数,出一和他本身以外不能被其他自然数整除。