Pagini recente » Cod sursa (job #1194013) | Cod sursa (job #2911976) | Cod sursa (job #1558924) | Cod sursa (job #431399) | Cod sursa (job #2076659)
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
//fractii ireductibile
float ireductibil(int x,int y)
{
int p=1;//presupunem ca e ireductibila
if(x%2==0 && y%2==0)p=0;
else if(x==y)p=0;
else if((x%2==0 && y%2==1) &&((x%y==0)||(y%x==0)))p=0;
return p;
}
int main()
{ int k=0; float n;
f>>n;
float i,j;
i=1;j=1;
while(i<=n)
{if(ireductibil(i,j))k++;
j++;
if(j==n)i++;
}
g<<k;
return 0;
}