Cod sursa(job #308896)

Utilizator ScriamTertiuc Afanasie Scriam Data 28 aprilie 2009 20:34:57
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.71 kb
Program fractii;
var n,i,j,k: longint;
    f,g : text;
function max(a,b : longint) : longint;
begin
if a>b then max:=a else max:=b;
end;

function min(a,b : longint) : longint;
begin
if a<b then min:=a else min:=b;
end;



function ireductibil(i,j : longint) : boolean;
var a:longint;
begin
ireductibil:=true;
if (i=1) and (j=1) then exit(true);
if (i<>1) and (j=1) then exit(true);
for a:=2 to max(i,j) do
if (i mod a=0) and (j mod a=0) then exit(false);
end;




begin
assign(f,'fractii.in');
reset(f);
readln(f,n);
close(f);
k:=0;

for i:=1 to n do
  for j:=1 to n do
    if ireductibil(i,j) then k:=k+1;
  assign(g,'fractii.out');
  rewrite(g);
  writeln(g,k);
  close(g);
end.