View Code of Problem 27

#include<stdio.h>

int main()
{
	int a,b;
	while(scanf("%d %d", &a,&b)!=EOF)
	{
		int x,sum =0;
		for(x=a+1;x<b;x++)
		{
			int isPrime=1;
			int i;
			for(i=2;i<x;i++)
			{
				if( x%i == 0 )
				{
					isPrime = 0;
					break;
				}
			}
			if ( isPrime == 1)
			{
				sum += x;
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 27