Pagini recente » Cod sursa (job #3361948) | Cod sursa (job #3362241) | Cod sursa (job #3363690) | Cod sursa (job #3361929) | Cod sursa (job #3363600)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
const int DIM = 1e6;
int phi[DIM + 5];
inline void prelucru(){
for(int i = 1 ; i <= DIM ; i++) phi[i] = i;
for(int i = 2 ; i <= DIM ; i++){
if(phi[i] == i){
for(int j = i ; j <= DIM ; j += i) phi[j] = phi[j] / i * (i - 1);
}
}
}
int main(){
int n; fin >> n;
prelucru();
long long rez= 1;
for(int i = 2 ; i <= n ; i++) rez += 2 * phi[i];
fout << rez;
}