Cod sursa(job #2926249)
| Utilizator | Data | 17 octombrie 2022 14:19:19 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main() {
int n;
fin >> n;
int ok = 1;
for (int i = 2; i <= n; ++i) {
if (i % 2 == 0 && i != 2) {
++ok;
} else if (i % 3 == 0 && i != 3) {
++ok;
} else if (i % 5 == 0 && i != 5) {
++ok;
} else if (i % 7 == 0 && i != 7) {
++ok;
}
}
fout << n - ok;
}
