Cod sursa(job #2427809)

Utilizator bucilamihai.iWNLMihai Cristian bucilamihai.iWNL Data 2 iunie 2019 12:40:22
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<fstream>
using namespace std;

ifstream fin("fractii.in");
ofstream fout("fractii.out");

int main()
{
    int n,i,j,k,r,x,y;
    fin>>n;
    k=2*n-1;
    for(i=2;i<=n;i++)
        for(j=2;j<=n;j++)
        {
            x=i;
            y=j;
            while(y)
            {
                r=x%y;
                x=y;
                y=r;
            }
            if(x==1)
                k++;
        }
    fout<<k;
}