Cod sursa(job #143970)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 26 februarie 2008 23:28:28
Problema Sum Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <stdio.h>

int cmmdc ( int x, int j) {
	if (j==0) return x;
	return cmmdc(j,x%j);
}

int main() {
int i,j,n,x,s; 
freopen("sum.in", "r", stdin);
freopen("sum.out", "w",stdout);
scanf("%d", &n);


for(i=0;i<n;++i)
	{s=0;
	scanf("%d", &x);
	
	for(j=1;j<=x*2;++j)
	  	if(cmmdc(x,j)==1) s=s+j;
        printf("%d\n", s);
	}	 

return 0;
}