题解 | #牛牛的素数和#

牛牛的素数和

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;
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务