Untitled

mail@pastecode.io avatar
unknown
c_cpp
11 days ago
394 B
1
Indexable
Never
#include <iostream>
#include <math.h>
using namespace std;

bool IsPrime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x % i == 0) return false;
	}
	return true;
}
int primesumm(int a, int b) {
	int summ = 0;
	for (int i = a; i <= b; i++) {
		if (IsPrime(i) == true) summ += i;
	}
	return summ;
}

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