Pagini recente » Cod sursa (job #2165187) | Monitorul de evaluare | Cod sursa (job #3206610) | Cod sursa (job #511663) | Cod sursa (job #2211823)
#include <iostream>
#include <stdio.h>
using namespace std;
int cr[1000001];
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
int n,i,r,j;
unsigned long long sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++) cr[i]=i;
for(i=1;i<=n;i++) {
sum+=cr[i];
r=n/i;
for(j=2;j<=r;j++)
cr[i*j]-=cr[i];
}
/**
p/q e ireductibila <=> q/p e ireductibila
scadem fr 1/1
**/
cout<<2*sum-1;
return 0;
}