java 求最大公约数
作者:互联网
package com.oop;
public class gongyueshu {
public static void main(String[] args) {
int result = getCommonDivisor(60, 120);
System.out.println(result);
}
public static int getCommonDivisor(int x, int y) {
if(y == 0) {
return x;
}
int z = x % y;
return getCommonDivisor(y, z);
}
}
标签:java,getCommonDivisor,int,最大公约数,static,result,return,public 来源: https://www.cnblogs.com/my-blog-site/p/16392069.html