Cod sursa(job #2617059)

Utilizator Marian1998Negrea Dumitru Marian Marian1998 Data 20 mai 2020 17:36:17
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.66 kb

#include<bits/stdc++.h>
using namespace std;

ifstream f("fractii.in");
ofstream g("fractii.out");
int GCD(int a, int b) {
	while (a != b)
	{
		if (a > b)
			a = a - b;
		else
			b = b - a;
	}
	return a;
}

int n,rez=0,numitor[1000001],numarator[1000001];
int main(void)
{
    f>>n;
    rez=n+n-1;
    for(int i=2;i<=n;i++){
        for(int j=2;j<=n;j++){
                numitor[i]=i;
                numarator[j+1]=j;
            while(numarator[j+1]!=0){
                if(GCD(numitor[i],numarator[j+1])==1){
                    rez+=1;
                }
        break;
            }
        }
    }
      g<<rez;
    return 0;
}