Pagini recente » Cod sursa (job #544922) | Cod sursa (job #41967) | Cod sursa (job #2210782) | Cod sursa (job #3128875) | Cod sursa (job #962900)
Cod sursa(job #962900)
#include<cstdio>
#define Nmax 1000005
using namespace std;
int n, phi[Nmax];
long long Nrf;
int main(){
freopen("fractii.in", "r", stdin);
scanf("%d", &n);
for(int i=1; i<=n; ++i)
phi[i]=i-1;
for(int i=2; i<=n; ++i){
Nrf+=phi[i];
for(int j=2*i; j<=n; j+=i)
phi[j]-=phi[i];
}
freopen("fractii.out", "w", stdout);
printf("%lld\n", 2*Nrf+1);
return 0;
}