题解 | #牛牛的素数和#
牛牛的素数和
https://www.nowcoder.com/practice/d748d79f68ab443482c5547d93824f50
#include <stdio.h> #include <math.h> int main() { int a, b; scanf("%d %d", &a, &b); int i,j,sum=0; for(i=a;i<=b;i++) { for(j=2;j<=sqrt(i);j++) { if(i%j==0) break; } if(j>sqrt(i)) sum+=i; } printf("%d\n",sum); return 0; }