Cod sursa(job #680771)
| Utilizator | Data | 15 februarie 2012 21:52:06 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include <stdio.h>
using namespace std;
long unsigned int cmmdc (long unsigned int a, long unsigned int b)
{
while (a!=b)
if (a>b)
a-=b;
else
b-=a;
return a;
}
int main ()
{
long unsigned int n, p, q, ct=0;
freopen ("fractii.in", "r", stdin);
freopen ("fractii.out", "w", stdout);
cin>>n;
for (p=1; p<=n; p++)
for (q=1; q<=n; q++)
if (cmmdc (p,q)==1)
ct++;
cout<<ct;
return 0;
}
