/**
* title : 辗转相除法
* Description: 求三个整数的最大公约数
* @author Mr Lv
* @date 2011-11-16
*/
public class lzwCode {
public static void main(String [] args) {
int a=36, b=48, c=72;
System.out.println(gcd(gcd(a,b),c));
}
public static int gcd(int a, int b) {
while (b != 0) {
int temp = a%b;
a = b;
b = temp;
}
return a;
}
}
辗转相除法
最新推荐文章于 2025-05-21 22:52:23 发布