package text1;
public class zuixiaogongbeishu {
public static void main(String[] args) {
int a=10;
int b=20;
System.out.println("最大公约数是:"+f(a, b));
}
private static int f(int a, int b) {
if(a<b){
int temp = a;
a=b;
b=temp;
}
if(a%b==0){
return b;
}else{
return f(b,a%b);
}
}
}
java求最大公约数
最新推荐文章于 2022-12-18 11:52:53 发布