Cod sursa(job #903868)

Utilizator georgetaGeorgeta Voinea georgeta Data 3 martie 2013 11:41:49
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.34 kb
#include<fstream>
using namespace std;
int n,m;
ifstream f("fractii.in");
ofstream g("fractii.out");
int cmmdc(int a, int b)
{if((!a) || (!b)) return a+b;
if(a>b) return cmmdc(a%b,b);
return cmmdc(a,b%a);}

int main()
{f>>n;
if(n>1){for(int i=2;i<=n;i++)for(int j=1;j<i;j++)if(cmmdc(i,j)==1)m++;
g<<m*2+1;}
else g<<'1';
return 0;}