public class Recu
{
public static void divisorMax(int a,int b)
{
int c = 0;
int d = 1;
if (b == 0)
{
System.out.println("最大公约数为:"+ a);
return;
}else
{
c = a/b;
d = a%b;
}
divisorMax(b,d); //递归调用此方法
}
public static void main(String[] args)
{
divisorMax(15,25);
}
}
通过递归算最大公约数
最新推荐文章于 2024-04-26 20:59:34 发布