Даны натуральные числа a и b, обозначающие соответственно числитель и знаменатель дроби. Сократить дробь.
program upr6;
var
a,b,c,i:integer;
bu:boolean;
begin
Write('a= ');
ReadLn(a);
Write('b= ');
ReadLn(b);
if a<b then c:=a else c:=b;
repeat
bu:=true;
i:=1;
repeat
inc(i);
if ((a mod i)=0) and ((b mod i)=0) then
begin
bu:=false;
a:=a div i;
b:=b div i;
c:=c div i;
end;
until i>c;
until bu;
WriteLn('New a= ',a);
WriteLn('New b= ',b);
ReadLn;
end.
Заранее спасибо!