Код:
![Выделить весь код](images/misc/selectcode.png)
var input,output:text;
n1,n2,d:real;
begin
assign(input,'input.txt'); reset(input);
assign(output,'output.txt'); rewrite(output);
readln(input,n1,n2);
if n1>=n2 then d:=n1;
if n2>=n1 then d:=n2;
while ((n1/d)<>trunc(n1/d)) OR ((n2/d)<>trunc(n2/d)) do
d:=d-1;
writeln(output,trunc(d));
close(input);
close(output)
end.
И ещё: для переменных n1,n2 лучше поставить тип integer, longint или int64, так как НОД только для натуральных чисел.
Для больших чисел он работает очень медленно. счас напишу получше алгоритм.