Skip to content

Greatest common divisor · ⁨最大公约数⁩

English

Greatest common divisor

The GCD of two numbers is the largest integer that divides both. Euclid's algorithm is beautifully short: while b isn't 0, replace the pair (a, b) with (b, a % b). When b reaches 0, a is the answer.

中文

最大公约数

两个数的最大公约数是能同时整除它们的最大整数。欧几里得算法非常简洁:当 b 不为 0 时,把 (a, b) 替换为 (b, a % b)。当 b 变为 0 时,a 就是答案。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩