View Code of Problem 27

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

Double click to view unformatted code.


Back to problem 27