Pagini recente » Cod sursa (job #1602449) | Cod sursa (job #2952838) | Cod sursa (job #1823832) | Cod sursa (job #2952834) | Cod sursa (job #2147858)
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h";
#include <fstream>
using namespace std;
int main()
{
ifstream in("fractii.in");
ofstream out("fractii.out");
int i, j, n, rest, max = 0, a, b;
in >> n;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
if ((i % 2 == 0) && (j % 2 == 0))
break;
if (j == 1)
max = max + 1;
else
{
a = i;
b = j;
while (b != 0)
{
rest = b;
b = a % b;
a = rest;
}
if (a == 1)
max = max + 1;
}
}
}
out << max;
}