View Code of Problem 27

#include<stdio.h>
int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
    {
        int sum=0;
        int i,j,temp;
        if(a>b)
        {
            temp=a;
            a=b;
            b=temp;
        }
        for(i=a+1;i<b;i++)
        {
            if(i==1)
                continue;
            int flag=0;
            for(j=2;j*j<=i;j++)
            {
                if(i%j==0)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==0)
                sum+=i;
        }
        printf("%d\n",sum);
    }

	return 0;
}

Double click to view unformatted code.


Back to problem 27