Pagini recente » Cod sursa (job #3221004) | Cod sursa (job #1944809) | Cod sursa (job #2613666) | Cod sursa (job #2597065) | Cod sursa (job #65265)
Cod sursa(job #65265)
#include <stdio.h>
unsigned long long nrprimecuxmaimicicax ( long x )
{
long d=7;
unsigned long long long h=1;
long dx=x;
if ( x % 2 ==0 )
{
dx/=2;
x/=2;
}
while ( x % 2 ==0 && x != 0 && x != 1 )
{
x/=2;
}
if ( x % 3 ==0 )
{
h*=2;
dx/=3;
x/=3;
}
while ( x % 3 ==0 && x != 0 && x != 1 )
{
x/=3;
}
if ( x % 5 ==0 )
{
h*=4;
dx/=5;
x/=5;
}
while ( x % 5 ==0 && x != 0 && x != 1 )
{
x/=5;
}
while ( x != 1 && x != 0 && d <= x )
{
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;
unsigned long long hhj=0;
for (i=2;i<=n;i++)
{
hhj+=nrprimecuxmaimicicax(i);
}
printf("%ulld",hhj*2+1);
fclose(stdout);
return 0;
}