Pagini recente » Cod sursa (job #1970445) | Cod sursa (job #505200) | Cod sursa (job #830243) | Cod sursa (job #502301) | Cod sursa (job #2511203)
#include <bits/stdc++.h>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
long long n, i, j, a, k, nmax, s;
long long indicator(long long n)
{
if(n == 0)
return 0;
long long rez = 1, d = 3, put = 0;
while(n % 2 == 0)
{
put++;
n /= 2;
}
if(put > 0)
rez *= (2 - 1) * pow(2, put - 1);
while(d * d <= n)
{
put = 0;
while(n % d == 0)
{
put++;
n /= d;
}
if(put > 0)
rez *= (d - 1) * pow(d, put - 1);
d += 2;
}
if(n > 1)
rez *= (n - 1);
return rez;
}
int main()
{
f >> n;
for(i = 1; i <= n; i++)
s += indicator(i);
g << (s * 2 - 1);
return 0;
}