Pagini recente » Cod sursa (job #2173336) | Cod sursa (job #2078338) | Cod sursa (job #2654743) | Cod sursa (job #182833) | Cod sursa (job #2780943)
#include <iostream>
#include <fstream>
using namespace std;
int e[1000001];
int main()
{
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
fin >> n;
for(int i = 2; i <= n; i++){
e[i] = i;
}
for(int i = 2; i <= n; i++){
if(e[i] == i){
for(int j = i; j <= n; j+=i){
e[j] = e[j] / i * (i - 1);
}
}
}
int nrf = 0;
for(int i = 2; i <= n; i ++){
nrf+=e[i];
}
nrf*=2;
nrf++;
fout << nrf;
fin.close();
fout.close();
return 0;
}