Pagini recente » Cod sursa (job #2048392) | Cod sursa (job #2635537) | Cod sursa (job #1771632) | Cod sursa (job #2878731) | Cod sursa (job #1094253)
#include <iostream>
using namespace std;
int CMMDC(int a, int b)
{
if (a == 0)
return b;
while (b != 0)
{
if (a > b)
a = a-b;
else
b = b-a;
}
return a;
}
bool exista_divizori_comuni(int a, int b)
{
if(CMMDC(a,b) == 1) return false;
else return true;
}
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
int a;
int solutie = 0;
scanf("%d",&a);
for(int i = 1; i <= a; i++)
{
for(int j = 1; j <= a; j++)
{
if(!exista_divizori_comuni(i,j)) solutie++;
}
}
printf("%d",solutie);
fclose (stdin);
fclose (stdout);
return 0;
}