Pagini recente » Cod sursa (job #2577257) | Cod sursa (job #2257689) | Cod sursa (job #3260361) | Cod sursa (job #2347600) | Cod sursa (job #2663741)
#include <fstream>
using namespace std;
typedef long long ll;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
const int NMAX = 1000005;
const int Nlim = 1000000;
int p[NMAX];
ll ans;
int n;
void totient() {
ll i, j, aux;
for(i = 2; i <= Nlim; i++) p[i] = i;
for(i = 2; i <= Nlim; i++) {
if(p[i] == i) {
p[i]--;
for(j = i << 1; j <= Nlim; j += i) {
p[j] /= i;
p[j] *= i - 1;
}
}
}
}
int main()
{
totient();
fin >> n; n++;
while(n--) ans += p[n];
ans <<= 1;
fout << ans + 1;
return 0;
}