1 solutions

  • 0
    @ 2024-12-5 18:19:39

    C++ :

    #include <iostream>
    using namespace std;
    int main() {
    int a = 0, b = 0, cnt = 0;
    cin >> a >> b;
    for (int n = a; n <= b; n++) {
    bool isPrime = true;
    for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
    isPrime = false;
    break;
    }
    }
    if (isPrime)
    cnt++;
    }
    cout << cnt << endl;
    return 0;
    }
    
    • 1

    Information

    ID
    9148
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By