Cod sursa(job #304553)

Utilizator otilia93Huszar Otilia otilia93 Data 13 aprilie 2009 20:27:50
Problema Fractii Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.53 kb
var a,b,nr,n,x,y:longint;
    f:text;
begin
  assign(f,'fractii.in');
  reset(f);
  read(f,n);
  close(f);
  nr:=0;
  for a:=1 to n do for b:=1 to n do begin
                                      x:=a;y:=b;
                                      while x<>y do if x>y then x:=x-y
                                                           else y:=y-x;
                                      if x=1 then nr:=nr+1;
                                    end;
  assign(f,'fractii.out');
  rewrite(f);
  write(f,nr);
  close(f);
end.