Cod sursa(job #251907)

Utilizator TudorutzuMusoiu Tudor Tudorutzu Data 3 februarie 2009 16:36:30
Problema Algoritmul lui Euclid Scor 20
Compilator fpc Status done
Runda Arhiva educationala Marime 0.43 kb
var f,g:text;
    i,t,a,b:longint;
function cmmdc(a,b:longint):longint;
begin
     if a=0 then cmmdc:=b;
     if b=0 then cmmdc:=a;
     if (a<>0)and(b<>0) then cmmdc:=cmmdc(a mod b,b mod a);
end;
begin
     assign(f,'euclid2.in'); reset(f);
     assign(g,'euclid2.out'); rewrite(g);
     readln(f,t);
     for i:=1 to t do
     begin
          readln(f,a,b);
          writeln(g,cmmdc(a,b));
     end;
     close(g);
end.