代码上:

unsigned int Gcd( unsigned int M, unsigned int N ){//计算最大公因数
      int Rem;

      while( N > 0 ){
            Rem = M % N;
            M = N;
            N = Rem;
      }
      return M;
}

如果应用递归的方法,代码如下:

unsigned int Gcd( int M, int N ){
      if( N == 0 ) return M;
      return Gcd( N , M % N );
}