Pagini recente » Cod sursa (job #405807) | Cod sursa (job #1464891) | Cod sursa (job #1761360) | Cod sursa (job #2923950) | Cod sursa (job #254129)
Cod sursa(job #254129)
var i,n,j,p,cop,d:longint;
s:int64;
t:array[1..1000000] of int64;
e:array[1..1000000] of 0..1;
begin
assign(input,'fractii.in');reset(input);
readln(n);
close(input);
for i:=1 to n do
e[i]:=1;
for i:=2 to n do
if e[i]=1 then begin
j:=2*i;
while j<=n do
begin
e[j]:=0;inc(j,i);
end;
end;
s:=0;
for i:=2 to n do
begin
if e[i]=1 then t[i]:=i-1
else
begin
d:=2;while i mod d<>0 do inc(d);
p:=1;cop:=i;
while cop mod d=0 do
begin
p:=p*d;
cop:=cop div d;
end;
if cop=1 then t[i]:=i-(i div d)
else t[i]:=t[p]*t[cop];
end;
s:=s+t[i];
end;
assign(output,'fractii.out');rewrite(output);
writeln(2*s+1);
close(output);
end.