#include <stdio.h> #include<math.h> int judge_prime(int num) { int flag = 0; for (int i = 2; i <= sqrt(num); i++) { if (num % i == 0) { return 0;//不是素数 } } return num;//是素数 } int main() { int l = 0; int r = 0; while (~scanf("%d %d", &l, &r)) { int sum = 0; for (int i = l; i <= r; i++) { int ret = judge_prime(i);//判断一个数是否是素数 sum += ret; } //输出 printf("%d\n", sum); } return 0; }