【C】#牛牛的素数和#
牛牛的素数和
https://www.nowcoder.com/practice/d748d79f68ab443482c5547d93824f50
#include <stdio.h> #include <math.h> int main() { int l, r, sum = 0; scanf("%d %d", &l, &r); for (int i = l; i <= r; i++) { int flag = 1; for (int j = 2; j <= sqrt(i); j++) { if (i % j == 0) { flag = 0; break; } } if (flag == 1) sum += i; } printf("%d", sum); return 0; }