Cod sursa(job #41951)

Utilizator silvia_the_bestSilvia Pripoae silvia_the_best Data 28 martie 2007 18:46:49
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.07 kb
var n,i,j,k,s:longint;
    f,g:text;
function ireductibil(x,y:longint):boolean;
         var a,i: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
     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;
             {v[k,1]:=i;
             v[k,2]:=j;}
             if ireductibil(i,j)=true then s:=s+1;
         end;
     {j:=0;
     for i:=1 to k do begin
         if ireductibil(v[i,1],v[i,2])=true then j:=j+1;
     end;}
     assign(g,'fractii.out');
     rewrite(g);
     writeln(g,s);
     close(g);
end.