Pagini recente » Cod sursa (job #383501) | Cod sursa (job #1226606) | Cod sursa (job #1360381) | Cod sursa (job #2408550) | Cod sursa (job #254128)
Cod sursa(job #254128)
var i,n,j,p,cop,d:longint;
s:longint;
t:array[1..10000] of longint;
e:array[1..10000] 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.