Cod sursa(job #134191)

Utilizator O_NealS. Alex O_Neal Data 10 februarie 2008 20:43:17
Problema Sum Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<fstream.h>
ifstream fin("sum.in");
ofstream fout("sum.out");
unsigned long long x,N,i,j;
unsigned long long s;

int cmmdc(long a, long b)

 {
              
              while(a!=b) { if(a>b) a-=b; else b-=a; }
              return b;
              
 }
 
int main()

 {  
    fin>>N;
    for(i=1; i<=N; i++)
       { fin>>x;
         s=0;
	 for(j=1; j<=2*x; j++)
              if(cmmdc(j,x)==1) s+=j; 
         fout<<s<<"\n";
       }
    return 0;
 }