Pagini recente » Cod sursa (job #408860) | Cod sursa (job #1389392) | Cod sursa (job #2547015) | Cod sursa (job #1508491) | Cod sursa (job #3350289)
#include <fstream>
int main() {
int n;
std::ifstream fin("fractii.in");
std::ofstream fout("fractii.out");
fin >> n;
long long phy[1000001];
for (int i = 0; i <= n; i++) { phy[i] = i; }
for(int i = 2; i <= n; i++) {
if (phy[i] == i) {
for(int j = i ; j <= n; j += i) {
phy[j] -= phy[j] / i;
}
}
}
long long result = 1;
for (int i = 2; i <= n; i++) {
result += 2 * phy[i];
}
fout << result;
}