Cod sursa(job #221052)
Utilizator | Data | 14 noiembrie 2008 11:25:21 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <stdio.h>
int n,p,q,aux,i,j,k,c;
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
scanf("%d",&n);
k=0;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
if (i>j)
{
p=i;
q=j;
}
else
{
p=j;
q=i;
}
while(q>0)
{
c=p%q;
p=q;
q=c;
}
if (p==1)
k=k+1;
}
printf("%d",k);
return 0;
}