Pagini recente » Cod sursa (job #1071422) | Cod sursa (job #3236794) | Cod sursa (job #1412710) | Cod sursa (job #2990027) | Cod sursa (job #39452)
Cod sursa(job #39452)
var n,i,j,k:longint;
d:boolean;
f,g:text;
v:array[1..10000,1..2] of integer;
function ireductibil(x,y:longint):boolean;
var a,i,d:longint;
label 1;
begin
if (x=1) and (y=1) then begin
ireductibil:=true;
goto 1;
end;
if x>y then a:=x
else if y>x then a:=y
else if x=y then a:=x;
for i:=2 to a do if (x mod i=0) and (y mod i=0) then begin
ireductibil:=false;
goto 1;
end;
ireductibil:=true;
1:end;
begin
assign(f,'fractii.in');
reset(f);
readln(f,n);
close(f);
for i:=1 to n do
for j:=1 to n do begin
k:=k+1;
v[k,1]:=i;
v[k,2]:=j;
end;
j:=0;
for i:=1 to k do begin
d:=ireductibil(v[i,1],v[i,2]);
if d=true then j:=j+1;
end;
assign(g,'fractii.out');
rewrite(g);
writeln(g,j);
close(g);
end.