Pagini recente » Cod sursa (job #391379) | Cod sursa (job #1232145) | Cod sursa (job #1759091) | Cod sursa (job #645849) | Cod sursa (job #612972)
Cod sursa(job #612972)
// fractii.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include "fstream.h"
int reduct(int x, int y)
{
int c, z=0;
if (x>y)
c=y;
else c=x;
for(int i=c; i>1; i--)
{
if((x%i==0)&&(y%i==0))
break;
if (i==2)
z=1;
}
return z;
}
int main()
{
ifstream input;
ofstream output;
input.open("input.in");
output.open("output.out");
int n;
input >> n;
int s=(n*2)-1;
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
{
if((i%j==0)||(j%i==0))
{}
else if(i==j)
{}
else s=s+reduct(i,j);
}
output << s;
return 0;
}