View Code of Problem 27

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <iomanip>
#include<vector>
#include<math.h>
using namespace std;
int issu(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0) {
			return 0;
		}
	}
	return 1;
}
int main()
{
	int a, b;

	while (cin >> a >> b){	
		int sum = 0;
		for (int i = a + 1; i < b; i++) {
			if (issu(i)) {
				sum += i;
			}
		}
		cout << sum<<endl;
	}
}

Double click to view unformatted code.


Back to problem 27