定理:gcd(a,b) = gcd(b,a mod b) (a>b 且a mod b 不为0)   
证明:a可以表示成a=kb+r,则r=a mod b
      假设d是a,b的一个公约数,则有
      d|a,d|b,而r=a-kb,因此d|r
      因此d也是(b,a mod b)的公约数   
      因此(a,b)和(b,a mod b)的公约数是一样的,其最大公约数也必然相等,得证

摘自百度百科:http://baike.baidu.com/view/1241014.htm

code:

      function gcd(a,b:longint):longint;
      begin
            if b=0 then exit(a);
            exit(gcd(b,a mod b)); 
      end;

相关文章:

  • 2021-08-22
  • 2021-07-20
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
  • 2021-08-26
  • 2022-12-23
  • 2022-02-22
相关资源
相似解决方案