View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27