Pagini recente » Cod sursa (job #2194505) | Cod sursa (job #544932)
Cod sursa(job #544932)
type natural=0..1000000;
var n:natural;
sum:int64;
Procedure Cit;
var f:text;
begin
assign(f,'fractii.in');
reset(f);
read(f,n);
close(f);
end;
Procedure Afis;
var f:text;
begin
assign(f,'fractii.out');
rewrite(f);
write(f,sum);
close(f);
end;
Function CMMDC(a,b:natural):natural;
begin
while a<>b do if a>b then a:=a-b
else b:=b-a;
if a=1 then cmmdc:=0
else cmmdc:=a;
end;
Procedure calc;
var i,j:natural;
begin
sum:=0;
for i:=1 to n do
for j:=1 to n do if CMMDC(i,j)=0 then inc(sum);
end;
Begin
Cit;
Calc;
Afis;
End.