Pagini recente » Cod sursa (job #825133) | Cod sursa (job #2039119) | Cod sursa (job #2678819) | Cod sursa (job #497381) | Cod sursa (job #1343970)
/*
* main.cpp
*
* Created on: Feb 16, 2015
* Author: levi
*/
#include <fstream>
using namespace std;
int gcd(int a, int b) {
if ((a==0)||(b==0)) return a+b;
if (a==b) return a;
if (a>b) return gcd(a-b,b);
else return gcd(a,b-a);
}
int main() {
ifstream fin;
ofstream fout;
fin.open("fractii.in");
int n, result = 0;
fin >> n;
fin.close();
fout.open("fractii.out");
for (int i=1; i<n+1 ; ++i ) {
for (int j = 1; j<i; ++j) {
if (gcd(i,j)==1) ++result;
}
}
result = result*2 + 1;
fout << result;
fout.close();
return 0;
}