Pagini recente » Cod sursa (job #2507598) | Cod sursa (job #2714718) | Cod sursa (job #1135162) | Cod sursa (job #1625462) | Cod sursa (job #1556008)
#include <fstream>
using namespace std;
long long v[100010], fi[100010];
long long n, x, i, j;
int main () {
ifstream fin ("sum.in");
ofstream fout("sum.out");
for (i=1;i<=100000;i++)
fi[i] = i;
for (i=2;i<=100000;i++)
if (v[i] == 0) {
for (j=i;j<=100000;j+=i) {
if (j!=i)
v[j] = 1;
fi[j] = fi[j]/i*(i-1);
}
}
fin>>n;
for(;n--;) {
fin>>x;
fout<<2*x*fi[x]<<"\n";
}
return 0;
}