Cod sursa(job #1082742)

Utilizator AzakaruPaul G Azakaru Data 14 ianuarie 2014 21:37:32
Problema Algoritmul lui Euclid Scor 30
Compilator fpc Status done
Runda Arhiva educationala Marime 0.43 kb
var T,i,j,a,b:integer;
    f,g:text;
    gasit:boolean;
begin
assign(f,'euclid2.in');reset(f);
assign(g,'euclid2.out');rewrite(g);
readln(f,T);
for i:=1 to T do begin
    gasit:=false;
    readln(f,a,b);
    if(a>b) then j:=b else j:=a;
    while(j>0) AND (gasit=false) do begin
              if (a MOD j=0) AND (b MOD j=0) then begin gasit:=true; writeln(g,j);end;
              j:=j-1;
              end;
end;
close(g);
end.