[20-04-26][Self-test 2]Java Prime Number
2021-02-06 20:17
标签:span i++ prime 多少 pack color test elf ret 结果如下: 101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,共计21个 [20-04-26][Self-test 2]Java Prime Number 标签:span i++ prime 多少 pack color test elf ret 原文地址:https://www.cnblogs.com/mirai3usi9/p/12781460.html 1 package test_1_2;
2
3 public class PrimeNum {
4
5 public static void main(String[] args) {
6
7 /** 判断101-200之间有多少个质数,并输出所有质数。 */
8
9 int count = 0;
10
11 for (int i = 100; i ) {
12 if (isPriNum(i) == true) {
13 System.out.print(i + ",");
14 count++;
15 }
16 }
17
18 System.out.println("共计" + count + "个");
19
20 }
21
22 /** 判断是否为质数 */
23 private static boolean isPriNum(int num) {
24
25 for (int i = 2; i ) {
26 if (num % i == 0) {
27 return false;
28 }
29 }
30
31 return true;
32 }
33
34 }
文章标题:[20-04-26][Self-test 2]Java Prime Number
文章链接:http://soscw.com/index.php/essay/51861.html