pgcd:=proc(a,b) local r: begin while (b>0) do r:=a mod b: a:=b: b:=r: end_while: return(a): end_proc;
-Version récursive :
pgcd:=proc(a,b) begin if (b=0) then return(a) else return(pgcd(b,a mod b)): end_if: end_proc;