View Code of Problem 27

#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int isPrime(int m){
	if(n==1) return 0;
	if(n==2) return 1;
	for(int i=2;i<=sqrt(m);i++){
		if(m%i==0){
			return 0;
			break;
		}
	}
	return 1;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)==2){
		if(a>b){
			int temp=a;
			a=b;
			b=temp;
		}
		int sum=0;
		for(int i=a+1;i<b;i++){
			if(isPrime(i)==1){
				sum+=i;
			}
		}
		printf("%d\n",sum);
	}
	
	
	return 0;
}
/*
Main.cc: In function 'int isPrime(int)':
Main.cc:9:5: error: 'n' was not declared in this scope
  if(n==1) return 0;
     ^
Main.cc:10:5: error: 'n' was not declared in this scope
  if(n==2) return 1;
     ^
*/

Double click to view unformatted code.


Back to problem 27