#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 <= 1) continue;
        bool esPrimo = true;
        for (int j = 2; j <= i / 2; j++) {
            if (i % j == 0) {
                esPrimo = false;
                break;
            }
        }
        if (esPrimo) {
            cout << i << " ";
            totalPrimos++;
        }
    }
    cout << "\nTotal de primos: " << totalPrimos << endl;
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: