/* ** euclid.src ** Author: Alan G. Isaac ** mailto:aisaac@american.edu ** Date: 28 June 2000 ** Caveat: this code is provided gratis but without ** any performance warrantee or guarantee ** **> euclid ** ** Purpose: find greatest common denominator of the ** largest and smallest elements of a matrix ** ** Format: x = euclid(mn); ** ** Input: mn matrix ** ** Output: x the greatest common denominator of the ** largest and smallest elements of a matrix ** ** Comments: uses only integer part of mn ** */ proc (1) = euclid(mn); local m,n,r; mn=vec(mn); mn=abs(int(maxc(mn)|minc(mn))); m=maxc(mn); n=minc(mn); r=m%n; do while r/=0; m=n; n=r; r=m%n; endo; retp(n); endp;