Pagini recente » Cod sursa (job #2027802) | Cod sursa (job #2061179) | Cod sursa (job #1997041) | Cod sursa (job #1146503) | Cod sursa (job #1717247)
/********************
Created by Sburly
********************/
#include <fstream>
using namespace std;
#define inf 100000
#define inf2 50000
long int n;
int totient[inf+1];
int main()
{
ifstream f("sum.in");
ofstream g("sum.out");
f >> n;
for (unsigned long int i=1;i!=inf;++i)
totient[i]=i;
for (unsigned long int i=2;i!=inf2;++i)
if (totient[i]==i)
for (unsigned long int j=i;j<=inf;j+=i)
totient[j] /=i, totient[j] *= (i-1);
for(unsigned long int i = n; i--;)
{
long long int x;
f >> x;
g << 2*x*totient[x] << '\n';
}
return 0;
}