#include <iostream>
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    int cnt = 0;
    int sum = 0;
    int f = 0;
    for (int i = n;i <= m;i++) {
        int cc = 0;
        for (int j = 1;j <= i;j++) {
            if (i % j == 0) {
                cc++;
            }
        }
        if (cc == 2) {
            if (cnt == 0) {
                f = i;
            }
            cnt++;
            sum+=i;
        }
    }
    cout << sum << "\n";
    cout << f;
    return 0;
}

Embed on website

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