View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27