Pagini recente » Cod sursa (job #2367568) | Cod sursa (job #959095) | Cod sursa (job #1653791) | Cod sursa (job #148043) | Cod sursa (job #123445)
Cod sursa(job #123445)
#include<stdio.h>
#include<math.h>
int main()
{
long n,i,j,p,x,f=0;
unsigned long e;
//int v;
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
scanf("%ld", &n);
for(i=2; i<=n; i++)
{
x=i;
p=0;
while(x%2==0)
{
p++;
x=x/2;
}
if(p>0)
e=(long unsigned int)pow(2,p-1);
else
e=1;
//v=0;
for(j=3; x!=1; j+=2)
{
if(x%j==0)
{
//v=1;
p=0;
while(x%j==0)
{
p++;
x=x/j;
}
e=(long unsigned int)e*(j-1)*pow(j,p-1);
}
}
/*if(v==0)
e=i-1;
else
{
for(k=j+2; x!=1; k+=2)
{
if(x%k==0)
{
p=0;
while(x%k==0)
{
p++;
x=x/k;
}
e=e*(k-1)*pow(k,p-1);
}
}
}*/
f=f+2*e;
}
f=f+1;
printf("%ld\n", f);
return 0;
}