您的位置:首页 > 其它

递归求解最大公约数

2013-11-29 11:33 134 查看
public class Gcd{

public static int gcd(int a,int b){

if(b==0)

return a;

else

return gcd(b,a%b);

}

public static void main(String[] args){

int a=4;

int b=6;

int temp=gcd(4,6);

System.out.println(temp);

}

}

算法思想:

辗转除法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: