Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <cmath>
- #include <vector>
- using namespace std;
- bool check(int& x) {
- for (int i = 3; i < x / 2; i+=2) {
- if (x % i == 0) {
- return false;
- }
- }
- return true;
- }
- int main() {
- int n;
- cin >> n;
- int temp = 0, i = 0;
- if (n % 2 == 0) {
- i = n + 1;
- }
- else {
- i = n + 2;
- }
- for (i; i < 2 * n; i+=2) {
- if (check(i))
- temp++;
- }
- cout << temp << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment