Pagini recente » Cod sursa (job #7477) | Cod sursa (job #1438774) | Cod sursa (job #613652) | Cod sursa (job #3190165) | Cod sursa (job #1717274)
/********************
Created by Sburly
********************/
#include <fstream>
using namespace std;
#define inf 100001
long int n;
int totient[inf];
int main()
{
ifstream f("sum.in");
ofstream g("sum.out");
f >> n;
int i,j;
for (i=inf-1;i;--i)
totient[i]=i;
for (i=2;i<inf;++i)
if (totient[i] == i)
for (j=i;j<inf;j+=i)
totient[j] /=i, totient[j] *= (i-1);
for(unsigned long int i = n; i--;)
{
int x;
f >> x;
g << (((unsigned long long int)x*totient[x])<<1) << '\n';
}
return 0;
}