Pagini recente » Borderou de evaluare (job #3120646) | Borderou de evaluare (job #1555701) | Borderou de evaluare (job #2244021) | Cod sursa (job #283322) | Cod sursa (job #1816634)
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
bool ired(int a, int b)
{
while(a&&b)
{
if(a<b)
swap(a,b);
a=a%b;
}
if(b==1)
return true;
else
return false;
}
int recurs(int x)
{
int t=2;
for(int i=2; i<x; i++)
if(ired(x, i))
t+=2;
if(x==1)
return 1;
else
{
return t+recurs(x-1);
fout<<"la pasul "<<x<<" se adauga "<<t<<endl;
}
}
int main()
{
int n;
fin>>n;
fout<<recurs(n);
}