int SumPrime(int n)
{
int i
int k
int sum=0
for(i=2i<=n++i )
{
for(k=2k<i++k)
{
if(i%k==0)
break
}
if(k == i) sum+= k
}
return sum
}
int main (void)
{
int n
int sum
printf("please enter a number:")
scanf("%d",&n)
sum=SumPrime(n)
printf("sum = %d\n",sum)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)