Pagini recente » Cod sursa (job #3290822) | Cod sursa (job #280292) | Cod sursa (job #2532185) | Monitorul de evaluare | Cod sursa (job #623152)
Cod sursa(job #623152)
#include <cstdio>
using namespace std;
int main()
{
freopen ("fractii.in","r", stdin);
freopen ("fractii.out","w", stdout);
int n, anz = 0, a;
float tot;
scanf ("%d", &n);
for (int i = 2; i <= n; i++)
{
tot = i;
a=i;
if (a%2==0)
{
tot*=1.0-1.0/2;
while (a%2==0)
a/=2;
}
for (int j=3;j<=n;j+=2)
if (a%j==0)
{
tot*=1.0-1.0/j;
while (a%j==0)
a/=j;
}
anz+=(int)tot;
}
printf ("%d \n", anz*2+1);
return 0;
}