package com.asiainfodemo;
public class Test {
public static void main(String[] args) {
int count = 0;
int i = 0;
int num=0;
for (i = 101; i < 200; i++) {
for (int j = 2; j < i; j++) {
if (i % j != 0) {
count++;
} else if (i % j == 0) {
break;
}
}
if (count == i - 2) {
System.out.print(i+",");
num++;
} else {
}
count = 0;
}
System.out.println();
System.out.println("素数的个数为:"+num);
}
}
判断101-200之间有多少个素数,并输出所有素数
最新推荐文章于 2024-02-20 06:17:09 发布