Pagini recente » Cod sursa (job #3121109) | Cod sursa (job #2743507) | Cod sursa (job #876048) | Cod sursa (job #890848) | Cod sursa (job #1489790)
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int a, int b)
{
for(int i=min(a,b); i>=2; i--)
{
if(a%i==0 && b%i==0)
{
return i;
}
}
return 1;
}
int main ()
{
ifstream read("fractii.in");
ofstream write("fractii.out");
int n;
read>>n;
int count = 2*n - 1, count2=0;
for(int i=2; i<=n; i++)
{
for(int j=i+1; j<=n; j++)
{
if(cmmdc(i,j)==1)
{
count2++;
}
}
}
count +=2*count2;
write<<count;
return 0;
}