View Code of Problem 27

#include<stdio.h>
#include<math.h>
int su(int n)
{    int i;
    if(n == 1)       
		return 0;
    if(n == 2)
        return 1;
    for(i = sqrt(n);i >= 2;i --)   
	{      if(n%i == 0)         
	return 0;    
	}  
 return 1;}

int main()
{
int a,b,i,temp;
int sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
	if(a>b){
	temp=a;a=b;b=temp;
	}
sum=0;
for(i=a+1;i<b;i++)
{
	if(su(i))
sum+=i;}
printf("%d\n",sum);
}
return 0;
}

Double click to view unformatted code.


Back to problem 27