1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> using namespace std; int num[246913] = { 0 }; int main() { int n, t = 0; for (size_t i = 2; i <= 246912; i++) { for (size_t j = 2; i*j <= 246912; j++) { num[i * j]++; } } for (bool k = 0; k == 0😉 { cin >> n; if (n != 0) { for (size_t i = n + 1; i <= 2 * n; i++) { if (num[i] == 0) t++; } cout << t << endl; t = 0; } else break; } return 0; } | cs |