Cod sursa(job #824581)

Utilizator get0000lostSatmarean Paul get0000lost Data 26 noiembrie 2012 19:22:30
Problema Algoritmul lui Euclid Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.45 kb
program euclid;
var f,g:text;i,j,nr,a,b,di:longint;
begin
 assign(f,'euclid2.in');
 assign(g,'euclid2.out');
 rewrite(g);
 reset(f);
 rewrite(g);
 readln(f,nr);
 for i:=1 to nr do
   begin
   read(f,a,b);
   if a>b
    then
     for j:=1 to b do
       if (b mod j=0) and (a mod j=0) then di:=j;
    if a<b then
     for j:=1 to a do
       if (a mod j=0) and (b mod j=0) then di:=j;
    writeln(g,di);
   end;
   close(f);
   close(g);
end.