Cod sursa(job #1283982)
Utilizator | Data | 6 decembrie 2014 10:00:18 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("frati.in");
ofstream g("frati.out");
int cmmdc(int a,int b)
{int r;
r=a%b;
while(r)
{
a=b;b=r;r=a%b;
}return b;
}
int main()
{ int n,i,j,s=0;
f>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
if(cmmdc(i,j)==1)s++;}
g<<s;
return 0;
}