Pagini recente » Cod sursa (job #2921297) | Cod sursa (job #1607457) | Cod sursa (job #1790666) | Cod sursa (job #1311654) | Cod sursa (job #2913378)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream cin("fractii.in");
ofstream cout("fractii.out");
int n;
cin >> n;
int nr=0;
for(int s=2; s<=n; s++)
{
for(int j=2; j<=n; j++)
{
int s_copy=s, j_copy=j;
while(j_copy)
{
int r=s_copy%j_copy;
s_copy=j_copy;
j_copy=r;
}
if(s_copy==1)
nr++;
}
}
nr+=2*n-1;
cout << nr;
return 0;
}