Pagini recente » Cod sursa (job #3229956) | Cod sursa (job #2999819) | Cod sursa (job #1942037) | Cod sursa (job #1299084) | Cod sursa (job #120517)
Cod sursa(job #120517)
#include <fstream.h>
using namespace std;
long long u[100001],tot[100001];
void totient()
{
long i,j;
for (i=2;i<=100001;i++)
tot[i]=i;
for (i=2;i<=100001;i++)
{
if (u[i]==0)
{
j=1;
while(i*j<=100001)
{
u[i*j]=1;
tot[i*j]=tot[i*j]-(tot[i*j]/i);
j++;
} }
}
}
int main()
{ long long n;
totient();
ifstream f1("sum.in");
ofstream f2("sum.out");
f1>>n;
sol=2*n*tot[n];
f2<<sol;
return 0;
}