判断1~200之间素数,并输出所有素数。
public class Test {标签:200,int,++,素数,num,public From: https://www.cnblogs.com/elexiangchirou/p/17128740.html
public static void main(String[] args) {
for (int i = 1; i < 200; i++) {
int num = 0;
for (int j = 1; j <= i/2; j++) {
if (i%j ==0){
num++;
}
}
if(num ==1){
System.out.println(i);
}
}
}
}