Pagini recente » Cod sursa (job #1453813) | Cod sursa (job #1806497) | Cod sursa (job #1658378) | Cod sursa (job #2086023) | Cod sursa (job #2268023)
#include <fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
const int VM=1000005;
int e[1000005];
int main()
{
int n,i;
in>>n;
e[1]=1;
for (int i = 2; i < VM; i++)
{
e[i] = i;
}
for (int i = 2; i < VM; i++)
{
if (e[i] == i)
{
for (int j = i; j < VM; j += i)
{
e[j] = e[j] / i * (i - 1);
}
}
}
int x;
for (int i=1;i<=n;i++)
{
in>>x;
out<<2*x*e[x];
}
return 0;
}