Pagini recente » Rating Ionescu Andrei (ionescumirceaandrei) | Cod sursa (job #1697480) | Cod sursa (job #902945) | Cod sursa (job #490218) | Cod sursa (job #1601025)
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
fin >> n;
int a[1000001];
for (int i = 2; i <= n; i++)
a[i] = i - 1;
for (int i = 2; i <= n; i++)
for (int j = i * 2; j <= n; j += i)
a[j] -= a[i];
long long s = 1;
for (int i = 2; i <= n; i++)
s += a[i] * 2;
fout << s << endl;
}