Untitled

mail@pastecode.io avatar
unknown
c_cpp
22 days ago
463 B
0
Indexable
Never
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
bool IsPrime(int a)
{
	for (int i = 2; i <= sqrt(a); i++)
	{
		if (a % i == 0)
		{
			return false;
		}
	}
	return true;
}
int SumPrime(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;
	int sum = SumPrime(a, b);
	cout << sum << endl;
}
Leave a Comment