Website Summary Files Commits Branches @commit @diff @stats
path: root / Week07 / Exercise11.cpp
blob: 5e5c3e4e15e876be9aed6355606ebf734a1fb9c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

bool isPrime(unsigned int x) {
	for (unsigned int div = 2; div < x; div++) {
		if (x % div == 0)
			return false;
	}
	return x > 1;
}

int main() {
	unsigned int a, b;
	std::cin >> a >> b;

	unsigned int count = 0;
	while (a <= b) {
		count += isPrime(a);
		a++;
	}

	std::cout << count << std::endl;

	return 0;
}