Untitled

mail@pastecode.io avatar
unknown
c_cpp
11 days ago
375 B
1
Indexable
Never
#include <iostream>
using namespace std;
bool prime(int a)
{
	for (int i = 2; i <= sqrt(a); i++)
	{
		if (a % i == 0) return false;
	}
	return true;
}
int sym(int a, int b, int sum = 0)
{
	for (; a <= b; a++)
	{
		if (prime(a) == true) sum += a;
	}
	return sum;
}
int main()
{
	int a, b, sum = 0;
	cin >> a >> b;
	a = a + 1;
	cout << sym(a, b, sum);
}
Leave a Comment