Cod sursa(job #1575875)
| Utilizator | Data | 21 ianuarie 2016 21:54:33 | |
|---|---|---|---|
| Problema | Sum | Scor | 35 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <cstdio>
using namespace std;
int n,x,j,i;
long long s;
int cmmdc(int a,int b)
{
int t;
while(b>=1)
{
t=a%b;
a=b;
b=t;
}
if(a==1)
return 1;
return 0;
}
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&x);
s=0;
for(j=1;j<=2*x;j++)
if(cmmdc(j,x)==1)
s+=j;
printf("%lld\n",s);
}
return 0;
}
