Pagini recente » Cod sursa (job #2447890) | Profil MiuCatalin | Monitorul de evaluare | Cod sursa (job #1138141) | Cod sursa (job #2271109)
#include <bits/stdc++.h>
using namespace std ;
ifstream fin("fractii.in") ;
ofstream fout("fractii.out") ;
float Euler(int x)
{
float nr = x ;
float y = x ;
if(x % 2 == 0)
{
while(x % 2 == 0)
x /= 2 ;
nr *= (1.0 - float(1.0/2)) ;
}
for(int d = 3 ; d <= x ; d += 2)
if(x % d == 0)
{
while(x % d == 0)
{
x /= d ;
}
float d1 = d ;
nr *= (1.0 - 1.0/d1) ;
}
return nr ;
}
int main()
{
ios_base::sync_with_stdio(false) ;
fin.tie(NULL) ;
int n ;
fin >> n ;
int nr = 0 ;
for(int i = 2 ; i <= n ; i += 1)
nr += (2 * Euler(i)) ;
nr += 1 ;
fout << nr ;
return 0 ;
}