GreatestCommonDivisor:gcd可以使用辗转相除法(欧几里得算法)
public class GreatestCommonDivisor { public static void main(String[] args) { int a = 12; int b = 18; System.out.println(gcd(a, b)); } public static int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } }模拟过程:
(1)gcd(12,18),return gcd(18, 12)
(2)gcd(18,12), return gcd(12, 6)
(3)gcd(12,6),return gcd(6, 0)
(4)gcd(6,0), return 6
两个数的最大公约数
最新推荐文章于 2021-06-12 21:07:51 发布
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Stable-Diffusion-3.5
图片生成
Stable-Diffusion
Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率
150

被折叠的 条评论
为什么被折叠?



