Pagini recente » Cod sursa (job #2499534) | Cod sursa (job #2967415) | Cod sursa (job #2685906) | Cod sursa (job #1410926) | Cod sursa (job #3273168)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
#define ll long long
ll n,rez;
inline ll phi(ll n)
{
ll d=2,r=n;
while(n>1&&d*d<=n)
{
if(n%d==0){
r=r/d*(d-1);
while(n%d==0) n/=d;
}
d++;
}
if(n>1) r=r/n*(n-1);
return r;
}
int main()
{
std :: iosbase :: sync_with_stdio (false);
std :: cin.tie(0);
fin>>n;
rez=1;
for(int i=2; i<=n; i++)
{
rez+=2*phi(i);
}
fout<<rez;
return 0;
}