Pagini recente » Cod sursa (job #319942) | Cod sursa (job #3162232) | Cod sursa (job #2146378) | Cod sursa (job #1017058) | Cod sursa (job #660641)
Cod sursa(job #660641)
#include <iostream>
#include <fstream>
using namespace std;
int ggt(int a, int b)
{
if (a%b == 0)
return b;
return ggt(b,a%b);
}
int euler(int n)
{
long long dummy = n;
int p=2,ct;
//cout << dummy << endl;
while (n>1)
{
ct=0;
while (n%p == 0)
n = n/p,ct++;
if (ct>0)
dummy = dummy/p*(p-1);
//cout << p << " " << ct << " " << dummy << endl;
p++;
}
return dummy;
}
int main(void)
{
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int a,x,ct=0;
fin>>a;
for(x=2;x<=a;x++)
{
ct += euler(x);
// cout << x << " " << euler(x) << endl;
}
ct=2*(ct)+1;
fout<<ct;
return 0;
}