Cod sursa(job #143968)

Utilizator ProcopliucProcopliuc Adrian Procopliuc Data 26 februarie 2008 23:23:43
Problema Sum Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
# include <stdio.h>
long int i,x,s,n,j;
int cmmdc (int a,int b)
{
if (a==b)
return a;
else
if (a>b)
return cmmdc (a-b,b);
else
return cmmdc (a,b-a);
}
int main ()
{
freopen ("sum.in","r",stdin);
freopen ("sum.out","w",stdout);
scanf ("%li",&n);
for (i=0;i<n;i++)
{s=1;
scanf ("%li",&x);
for (j=2;j<2*x;j++)
if (cmmdc (x,j)==1)
s=s+j;
printf ("%li\n",s);
}
return 0;
}