View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27