通过递归算最大公约数

xiaoxiao2021-02-28  131

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); } }

转载请注明原文地址: https://www.6miu.com/read-34409.html

最新回复(0)