Pagini recente » Cod sursa (job #767783) | Cod sursa (job #439168) | Cod sursa (job #1282329) | Cod sursa (job #2879802) | 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);
}