var a, b: integer; Begin Write(‘nhap a va b: ‘); readln(a,b); Write(a, ‘/’, b, ‘ = ‘); If a=b then write(‘1/1’) else If a>b then while a mod b = 0 do Begin a:=a div b; b:=1; End Else while b mod a = 0 do Begin b:=b div a; a:=1; End; Write(a, ‘/’, b); Readln End. Bình luận
var a, b: integer;
Begin
Write(‘nhap a va b: ‘); readln(a,b);
Write(a, ‘/’, b, ‘ = ‘);
If a=b then write(‘1/1’) else
If a>b then while a mod b = 0 do
Begin
a:=a div b; b:=1;
End
Else while b mod a = 0 do
Begin
b:=b div a; a:=1;
End;
Write(a, ‘/’, b);
Readln
End.