③求最大公约数子函数,返回两个正整数的最大公约数,采用辗转相除法算法;
function gcd(a,b:longint):longint;
begin
if b=0 then gcd:=a
else gcd:=gcd(b,a mod b);
end;