Pagini recente » Cod sursa (job #175567) | Cod sursa (job #1584790) | Cod sursa (job #386496) | Cod sursa (job #2413957) | Cod sursa (job #282329)
Cod sursa(job #282329)
Program fractii;
var n,i,j,nr: longint;
var f:text;
Function cmmdc(x,y: longint):longint;
var i,j: integer;
begin
cmmdc:=1;
if (x>=y) and (y<>1) then
for i:=y downto 2 do
if (x mod i=0) and (y mod i=0) then begin
cmmdc:=i;
break;
end;
if (x<y) and (x<>1) then
for i:=x downto 2 do
if (x mod i=0) and (y mod i=0) then begin
cmmdc:=i;
break;
end;
end;
begin
nr:=0;
assign(f,'fractii.in'); reset(f);
read(f,n);
close(f);
for i:=1 to n do
for j:=1 to n do
if cmmdc(i,j)=1 then nr:=nr+1;
assign(f,'fractii.out'); rewrite(f);
write(f,nr);
close(f);
end.