Pagini recente » Cod sursa (job #2180643) | Cod sursa (job #1237145) | Cod sursa (job #1979414) | Cod sursa (job #1550067) | Cod sursa (job #1893676)
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
typedef long long i64;
const int nmax=1000000;
i64 v[nmax+1];
int main () {
int n;
fin>>n;
for (int i=1; i<=n; i++) {
v[i]=i;
}
for (int i=2; i<=n; i++) {
if (v[i]==i) {
for (int j=i; j<=n; j+=i) {
v[j]/=i;
v[j]*=(i-1);
}
}
}
i64 sol=0;
for (int i=2; i<=n; i++) {
sol+=v[i];
}
fout<<2*sol+1;
return 0;
}