跳到主要内容

资源 · 指南或文章

Euclidean algorithm

通过反复相减介绍欧几里得求最大公约数的方法,并配有几何示意图。

审核日期

打开原站: Euclidean algorithm (在新标签页中打开原网站)

添加到路线图

把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。

来源内容语言:英语

In mathematics, the Euclidean algorithm, or Euclid's algorithm, is an efficient method for computing the greatest common divisor (GCD) of two numbers, the largest number that divides both of them without leaving a remainder. The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number. For example, 21 is the GCD of 252 and 105 (as 252 = 21 × 12 and 105 = 21 × 5), and the same number 21 is also the GCD of 105 and 252 − 105 = 147. Since this replacement reduces the larger of the two numbers, repeating this process gives successively smaller pairs of numbers until the two numbers become equal. When that occurs, they are the GCD of the original two numbers. By reversing the steps, the GCD can be expressed as a sum of the two original numbers each multiplied by a positive or negative integer, e.g., 21 = 5 × 105 + (−2) × 252. The fact that the GCD can always be expressed in this way is known as Bézout's identity.

PrepKit 概览

本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。

适合人群
来源未说明适用级别
形式
参考资料

涵盖内容

  • 用两数之差替换较大的数,最大公约数保持不变,以 252 和 105 为例
  • 贝祖等式:21 = 5 乘以 105 加上 -2 乘以 252
  • 24 乘 60 的铺砖示意图,以及一段把 1071 和 462 约简到 21 的动画

使用建议

这是 PrepKit 的学习建议,并非来源的说法。

分别编写相减版和取余版,比较 1071 和 462 所需的步数,再加上扩展算法,重现贝祖系数。

范围与局限

只有相减形式:没有取模形式、扩展算法或运行时间分析。

获取方式与形式

GitHub 上采用 MIT 许可的 trekhleb/javascript-algorithms 仓库中的免费英文 README。

PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88

本概览的依据
  • src/algorithms/math/euclidean-algorithm/README.md

收录此条目的页面

订阅 PrepKit 通讯

可选。使用 PrepKit 并不需要订阅。

我们如何处理你的邮箱