View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27