Pagini recente » Cod sursa (job #916117) | Cod sursa (job #2688354) | Cod sursa (job #2062268) | Cod sursa (job #3139216) | Cod sursa (job #89440)
Cod sursa(job #89440)
var n,i,j,k,s:longint;
f,g:text;
function ireductibil(x,y:longint):boolean;
{Functia da valoarea true daca fractia x\y este ireductibila
si false in caz contrar}
var a,i:longint;
ir:boolean;
begin
ir:=true;
if (x<>1) or (y<>1) then begin
if y>=x then a:=x
else a:=y;
i:=1;
while (i<a) and (ir=true) do begin
i:=i+1;
if (x mod i=0) and (y mod i=0) then ir:=false;
end;
end;
ireductibil:=ir;
end;
begin
s:=0;
k:=0;
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;
if ireductibil(i,j)=true then s:=s+1;
end;
assign(g,'fractii.out');
rewrite(g);
writeln(g,s);
close(g);
end.