View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27