Untitled
#include <iostream> using namespace std; bool prime(int x) { for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) return false; } return true; } int primesumm(int a, int b) { int summ = 0; for (int i = a; i <= b; i++) { if (prime(i) == true) summ += 1; } return summ; } int main() { int a; int b; cin >> a; cin >> b; cout << primesumm(a, b); }
Leave a Comment