Cod sursa(job #999650)

Utilizator SkillZoneOvy The Best SkillZone Data 21 septembrie 2013 10:02:09
Problema Sum Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.35 kb
#include<fstream>
using namespace std;

int cmmdc(int a, int b){
	if(a%b==0)
		return b;
	else
		return cmmdc(b, a%b);
}

int main(){
	int n,x;
	long long s;
	ifstream f("sum.in");
	ofstream g("sum.out");
	f>>n;
	for(int i=0;i<n;i++){
		f>>x;
		s=0;
		for(int j=1;j<=x*2;j++)
			if(cmmdc(j,x)==1)
				s+=j;
		g<<s<<'\n';
	}
	return 0;
}