Cod sursa(job #3227455)
Utilizator | Data | 30 aprilie 2024 19:28:37 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main() {
int n;
fin >> n;
int r = n, d = 2;
while(n > 1) {
if (n % d == 0) {
r = r / d * (d - 1);
while(n%d==0) {
n /= d;
}
}
d++;
if (d * d > n) {
d = n;
}
}
fout << r;
}