Pagini recente » Cod sursa (job #2095237) | Cod sursa (job #2309718) | Cod sursa (job #1094252)
#include <iostream>
using namespace std;
bool exista_divizori_comuni(int a, int b)
{
for(int i = min(a, b); i >= 2; i--)
{
if(a % i == 0 && b % i == 0)
{
return true;
}
}
return false;
}
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;
}