MyGCD := function(a,b)
    q,r := Quotrem(a,b);
    as := [a, b]; qs := [q];
    i := 1;
    while r ne 0 do
        i := i+1;
        Append(~as, r);
        q,r := Quotrem(as[i], as[i+1]);
	Append(~qs, q);
    end while;
    d := as[#as];
    if d lt 0 then
        d := -d;
    end if;
    return d;
end function;
