View Code of Problem 27

#include<iostream>
using namespace std;
//求素数
bool sushu(int a)
{   int n=0;
	for(int i=2;i<a;i++)
	  if(a%i==0) 
	    n++;
	if(n==0) return true;
	 else return false;
}
 
int main()
{
	int a,b;
	while(cin>>a>>b)
	{   int sum=0;
		for(int i=a+1;i<b;i++)
		  if(sushu(i))
		     sum+=i;
		     
	    cout<<sum<<endl;
	}
	
	
}
 

Double click to view unformatted code.


Back to problem 27