Untitled

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

int IsPrime(int a2) {
	bool count = 1;
	for (int i = 2; i < a2 - 1; i++)
	{
		if (a2 % i == 0) {
			count = false;

		}
	}

	return count;

}

int sum(int a, int b) {
	int sum = 0;
	for (int a2 = a; a2 < b+1; a2++)
	{
		if (IsPrime(a2) == 1) {
			sum += a2;
		}
	}
	return sum;
}



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