展开全部
#include <math.h>
#include <stdio.h>
int is_prime(int n){
int i=0;
if(n%2==0){
return 0;
}
for(i=3;i<=sqrt((double)n);i+=2){
if(n%i==0)
return 0;
}
return n;
}
void main(){
int i=0;
int sum=0;
for(i=3;i<=100;i++){
sum+=is_prime(i);
}
printf("the prime number between 3 and 100 sum is:%d\n",sum);
}
#include <stdio.h>
int is_prime(int n){
int i=0;
if(n%2==0){
return 0;
}
for(i=3;i<=sqrt((double)n);i+=2){
if(n%i==0)
return 0;
}
return n;
}
void main(){
int i=0;
int sum=0;
for(i=3;i<=100;i++){
sum+=is_prime(i);
}
printf("the prime number between 3 and 100 sum is:%d\n",sum);
}
参考资料: http://hi.baidu.com/hking1987/blog/item/3c9525f50db21d66ddc4749b.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询