Pagini recente » Profil Monstergentleman35 | Cod sursa (job #1551343) | Monitorul de evaluare | Statistici claudiu (watfa2017) | Cod sursa (job #934489)
Cod sursa(job #934489)
#include <iostream>
#include <fstream>
std::ifstream fin("fractii.in");
std::ofstream fout("fractii.out");
//std::ifstream fin("date.in");
//std::ofstream fout("date.out");
long cmmdc(long a, long b)
{
if(!b)
{
return a;
}
else
{
return cmmdc(b, a%b);
}
}
void citeste()
{
long n = 0;
fin>>n;
long nr = n;
for(long i = 2 ; i <= n ; i++)
{
for(long j = i; j <= n ; j++)
{
if(cmmdc(i, j) == 1)
{
// std::cout<<i<<" "<<j<<'\n';
nr++;
}
}
}
nr = nr * 2 - 1;
// std::cout<<'\n';
// std::cout<<nr<<'\n';
fout<<nr;
}
int main()
{
citeste();
return 0;
}