Cod sursa(job #328883)

Utilizator cosmyoPaunel Cosmin cosmyo Data 3 iulie 2009 17:45:29
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<iostream.h>
#include<fstream.h>
long cmmdc(long a,long b)
{if (b==0)
	return a;
else
	return cmmdc(b,a%b);
}
long n;
int main()
{ifstream fin("fractii.in");
  fin>>n;
 fin.close(); 
 ofstream fout("fractii.out");
 long i,j,nr;
 nr=1;
 for(i=2;i<=n-1;i++)
 {//fout<<i-1<<" "<<nr<<"\n";
  for(j=1;j<=i-1;j++)
	  if(cmmdc(i,j)==1)
	//	 fout<<i<<'/'<<j<<" ";
		//else	 
	  nr+=2;
        
 }
 fout<<nr;
 fout.close();
 return 0;
}