Pagini recente » Cod sursa (job #489379) | Cod sursa (job #2798186) | Cod sursa (job #47956) | Cod sursa (job #2348503) | Cod sursa (job #120512)
Cod sursa(job #120512)
#include <fstream.h>
using namespace std;
long long u[100001],tot[100001];
void totient()
{
long i,j;
for (i=2;i<=100000;i++)
tot[i]=i;
for (i=2;i<=100000;i++)
{
if (u[i]==0)
{
j=2;
tot[i]--;
while(i*j<=100000)
{
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;
f2<<n*2*tot[n];
return 0;
}