program main !辗转相除法 integer m,n common m,n print*,'Please input two positive integers:' read(*,*) m,n call Euclid(m,n) endprogram subroutine Euclid(m,n) integer r do while(n.ne.0) r = mod(m,n) m = n n = r enddo print*,'Their greatest common divisor is', m endsubroutine