public static void main(String[] args) {
for (int i = 2; i < 100; i++) {
int factors = 0;
for (int j = 1; j < (i + 2) / 2; j++) {
if ((i % j) == 0)
factors++;
}
if (factors < 2)
System.out.println(i + " is prime");
}
}
用JAVA来寻找和打印素数
最新推荐文章于 2023-05-25 11:06:46 发布