#include <iostream>
using namespace std;
int main() {
int a, b, totalPrimos = 0;
cout << "Inicio: ";
cin >> a;
cout << "Fin: ";
cin >> b;
for(int i = a; i <= b; i++) {
if(i < 2) continue;
bool esPrimo = true;
for(int j = 2; j * j <= i; j++) {
if(i % j == 0) {
esPrimo = false;
break;
}
}
if(esPrimo) {
cout << i << " ";
totalPrimos++;
}
}
cout << "\nTotal de primos: " << totalPrimos << "\n";
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: