Pagini recente » Cod sursa (job #408319) | Cod sursa (job #779097) | Cod sursa (job #535570) | Cod sursa (job #1888360) | Cod sursa (job #694468)
Cod sursa(job #694468)
function cmmdc(a,b:longint):longint;
begin
while a<>b do
if a>b then
a:=a-b
else
b:=b-a;
cmmdc:=a;
end;
var a,b:longint;
t:longint;
f1,f2:text;
begin
assign(f1,'euclid2.in');
assign(f2,'euclid2.out');
reset(f1); rewrite(f2);
readln(f1,t);
for i:=1 to t do
begin
read(f1,a,b);
writeln(f2,cmmdc(a,b));
readln(f1);
end;
close(f1);
close(f2);
end.