Untitled

mail@pastecode.io avatar
unknown
c_cpp
15 days ago
388 B
0
Indexable
Never
#include <iostream>
using namespace std;

bool IsPrime(int x) {
	for (int i = 0; i < sqrt(x); i++) {
		if (x % i == 0) {
			return false;
		}
		return true;
	}
}

int div2(int a, int b) {
	int sum = 0;
	for (int i = a; i <= b; i++) {
		if (IsPrime(i) == true) {
			sum += i;
		}
	}
	return sum;
}

int main()
{
	int a, b;
	cin >> a >> b;
	cout << div2(a, b);
} 
Leave a Comment