最大公约数的的另一种求法

来源:互联网 发布:淘宝怎么抢购最快 编辑:程序博客网 时间:2024/05/21 08:59
public class GongYue{    public static void main(String[] args){   System.out.println(getGb(104,108));   }public static int getGy(int a,int b){   while(a!=b)   {   if(a>b)   a=a-b;   else   b=b-a;   }   return a;}}
有了最大公约数,最小公倍数不是问题了吧~~~~
原创粉丝点击