Pagini recente » Cod sursa (job #2220227) | Cod sursa (job #793990) | Cod sursa (job #1661436) | Cod sursa (job #1097210) | Cod sursa (job #1355310)
#include <fstream>
#include <iostream>
#define tip unsigned long long
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
tip n;
tip sol(tip p); tip aux(tip l); tip cmmdc(tip a, tip b);
int main()
{
fin>>n;
fout<<sol(n);
fin.close(); fout.close(); return 0;
}
tip cmmdc(tip a, tip b)
{
while(a!=b)
{
if(a>b) a-=b; else if(a<b) b-=a;
}
return a;
}
tip aux(tip l)
{
tip sc=0;
for(tip i=2; i<=l; i++)
if(cmmdc(l, i)!=1) sc++;
return sc;
}
tip sol(tip p)
{
if(p==1) return 1;
else
{
return sol(p-1)+2*(p-aux(p));
}
}
//rezolvare cu recursivitate;