Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
430 B
0
Indexable
Never
#include <iostream>
#include <cmath>
using namespace std;
bool IsPrime(int x)
{
	float b;
	int l = 0;
	b = sqrt(x);
	for (int i = 2; i <= b; i++) {
		if (x % i == 0) {
			return 0;
		}
	}
	return 1;
}

int summe(int a, int b) {

	
	int summ = 0;
	for (int y = a; y <= b; y++) {
	
		if (IsPrime(y) == 1) summ += y;
	}
	return summ;
}

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