Pagini recente » Cod sursa (job #124577) | Cod sursa (job #2685872) | Cod sursa (job #2903312) | Cod sursa (job #2251284) | Cod sursa (job #1202889)
#include<fstream>
using namespace std;
ifstream fi("sum.in");
ofstream fo("sum.out");
const int maxn = 100000;
int phi[maxn+5];
int t,x;
void indicator_euler(){
int i,j;
for(i=1;i<=maxn;i++) phi[i]=i;
for(i=2;i<=maxn;i++)
if(phi[i]==i)
for(j=i;j<=maxn;j+=i) phi[j]-=(phi[j]/i);
}
int main(){
indicator_euler();
fi>>t;
while(t){
fi>>x;
fo<<2LL*x*phi[x]<<"\n";
t--;
}
fi.close();
fo.close();
return 0;
}