View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27