Function nod(a, b: integer): integer;
var
i, c: integer;
begin
if a > b then c := a else c := b;
for i := c downto 1 do
if ((a mod i) = 0) and ((b mod i) = 0) then begin nod := i; break; end;
end;
var
a, b: integer;
begin
Write('Введите два числа ');
Readln(a, b);
write('НОД чисел ', a, ' и ', b, ' равен ');
if (a = 0) or (b = 0) then write('0') else write(nod(a, b));
end.