Cod sursa(job #421542)

Utilizator thewallDango David Narcis thewall Data 21 martie 2010 14:34:38
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <iostream>
#include <fstream>
using namespace std;

long cmmdc(long i,long j) {
	 if(i%j==0) return j;
	 else return cmmdc(j,i%j);
}

int main() {
	long n,t=0,i,j;
	ifstream f("fractii.in");
	f>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(cmmdc(i,j)==1)
				t++;
	ofstream g("fractii.out");
	g<<t;
	f.close();
	g.close();
	return 0;
}