Cod sursa(job #2293789)
Utilizator | Data | 1 decembrie 2018 16:23:30 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int euclid(int a, int b)
{
int r;
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
return a;
}
long long n,i,k,nr;
int main()
{
fin>>n;
k=1;
nr=0;
while(k<=n)
{
for(i=1;i<=n;i++)
{
if(euclid(k,i)==1)
nr++;
}
k++;
}
fout<<nr;
}