Pagini recente » Cod sursa (job #67466) | Cod sursa (job #3264511) | Cod sursa (job #2397319) | Cod sursa (job #1538650) | Cod sursa (job #2916254)
#include <fstream>
std::ifstream in("fractii.in");
std::ofstream out("fractii.out");
int64_t totient(int64_t x) {
int64_t n = x;
int64_t p = 2;
while (x > 1) {
if (x % p == 0) {
n *= p - 1;
n /= p;
while (x % p == 0) x /= p;
}
p++;
}
return n;
}
int main() {
int64_t answer = 1;
int64_t x;
in >> x;
for (int64_t i = 2; i <= x; i++) answer += 2 * totient(i);
out << answer;
}