View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27