class Main {
public static void main(String[] args) {
int result1 = splitS1(21,3);
System.out.println("结果为:"+result1);
int result2 = splitS2(21,3);
System.out.println("结果为:"+result2);
}
//递归
public static int splitS1(int l,int w){
if(l%w==0) return w;
return splitS1(w,l%w);
}
//递推
public static int splitS2(int l,int w){
int temp = 0;
while(w!=0){
temp = l % w;
l = w;
w = temp;
}
return l;
}
}