Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int PrimeNumber(long long n, long long m) {
- vector<int> Prime;
- int p, i = 1;
- long long sum = 0, count = 1;
- Prime.insert(Prime.end(), 2);
- while (count < m) {
- for (int j = 0; j < Prime.size(); j++) {
- if (i % Prime[j] == 0) {p += 1; break;}
- }
- if (p == 0) {count += 1; Prime.insert(Prime.end(), i); if (count >= n) {sum += i;};}
- else p = 0;
- i += 2;
- }
- if (n == 1) sum += 2;
- return sum;
- }
- int main() {
- long long n, m;
- cin >> n >> m;
- cout << PrimeNumber(n, m);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement