Cod sursa(job #1169232)

Utilizator scorpionmkBancila Petru Armand scorpionmk Data 10 aprilie 2014 18:39:37
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int n,a,b;

int cmmdc (int u, int v){
	int y,x=0;
    int g=v;if (u<v) g=u;

    while (x<=g){
        ++x;
        if (u%x==0 && v%x==0) y=x;
        if (y>1) return 0;

    }
return 1;
}

int main(){
    int nr=0;
    in>>n;
    for (a=1;a<=n;a++)
    {
        for (b=1;b<=n;b++)
		{if (a!=b||b==1||a%b==0||a!=1)  nr+=cmmdc(a,b);}}
    out<<nr;
}