Pagini recente » Cod sursa (job #2717061) | Cod sursa (job #835960) | Cod sursa (job #2554887) | Cod sursa (job #690709) | Cod sursa (job #29665)
Cod sursa(job #29665)
#include <stdio.h>
long nrprimecuxmaimicicax ( long x )
{
long d=7;
long h=1;
long dx=x;
if ( x % 2 ==0 )
{
dx/=2;
}
while ( x % 2 ==0 && x != 0 )
{
x/=2;
}
if ( x % 3 ==0 )
{
h*=2;
dx/=3;
}
while ( x % 3 ==0 && x != 0 )
{
x/=3;
}
if ( x % 5 ==0 )
{
h*=4;
dx/=5;
}
while ( x % 5 ==0 && x != 0 )
{
x/=5;
}
while ( x != 1 && x != 0 )
{
if ( x % d == 0 )
{
dx/=d;
x/=d;
h=h*(d-1);
}
while ( x % d == 0 && x != 0 && x != 1)
x/=d;
d+=2;
}
return dx*h;
}
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
long n;
scanf("%ld",&n);
long i;
long long hhj=0;
/* for (int j=2;j<=20000;j++)
{*/
for (i=2;i<=n;i++)
{
hhj+=nrprimecuxmaimicicax(i);
}
printf("%lld",hhj*2+1);
fclose(stdout);
return 0;
}