Cod sursa(job #2254675)

Utilizator Rares_99Savin Rares Rares_99 Data 5 octombrie 2018 18:59:27
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <fstream>

using namespace std;

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

bool PrimeIntreEle(int x, int y)
{
    int r;
    r = x%y;
    while(r!=0)
    {
        x=y;
        y=r;
        r=x%y;
    }
    if(y==1) return true;
    return false;
}

int main()
{
    int n,valor;
    fin>>n;
    int nr = 0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    {
        valor = PrimeIntreEle(i, j);
        if(valor)
        {   nr++;
        }
    }
    fout<<nr;
    return 0;
}