Pagini recente » Cod sursa (job #1323327) | Cod sursa (job #1364346) | Cod sursa (job #656036) | Cod sursa (job #625938) | Cod sursa (job #44428)
Cod sursa(job #44428)
var n,i,s:longint;
f,g:text;
function euler(x:longint):longint;
var p,i,j:longint;
b:boolean;
begin
p:=x;
if x mod 2=0 then p:=p div 2;
if x=2 then p:=1
else if x=3 then p:=2
else if x=4 then p:=2
else if x=5 then p:=4
else begin
for i:=3 to {trunc(sqrt(}x{))+1} do
if x mod i=0 then begin
j:=1;
b:=true;
while (j<i-1) and (b=true) do begin
j:=j+1;
if i mod j=0 then b:=false;
end;
if b=true then p:=p*(i-1) div i;
end;
end;
euler:=p;
end;
begin
assign(f,'fractii.in');
reset(f);
readln(f,n);
close(f);
for i:=1 to n do s:=s+euler(i)*2;
assign(g,'fractii.out');
rewrite(g);
writeln(g,s-1);
close(g);
end.