package com.zfy;
/**
* @author 江湖@小小白
* @create 2021/9/23 9:35
*/
public class Test {
public static void main(String[] args) {
int sum = 0;
for (int i = 2; i <= 100 ; i++) {
boolean flag = true;
for (int j = 2; j < i ; j++) {
if (i%j == 0){
flag = false;
break;
}
}
if (flag){
sum += i;
}
}
System.out.println(sum);
}
}
求1~100之间的质数和
最新推荐文章于 2022-09-28 22:55:42 发布