# 扩展欧几里得算法（Extended Euclidean algorithm，extended_gcd）

两个整数的最大公因数，以及得到它的乘数。

## 怎么写

### extended_gcd(a, b)

**a**

一个整数。接受一个整数。

**b**

一个整数。接受一个整数。

## 示例

- $\displaystyle \operatorname{extended\_gcd}(12, 18) = \left[ 6, \left[ -1, 1 \right] \right]$

  `extended_gcd(12, 18)`

  在求解器中，`extended_gcd(12, 18)` 的结果是 `[6, [-1, 1]]`。

  [在求解器中打开](https://zh.hilberon.com/?q=extended_gcd%2812%2C%2018%29)

## 相关函数

- [factor_integer](https://zh.hilberon.com/library/factor_integer)

  整数的质因数分解，以质数和指数成对的列表给出。
- [euler_phi](https://zh.hilberon.com/library/euler_phi)

  欧拉函数：不超过 n 且与 n 互质的整数有多少个。
- [fibonacci](https://zh.hilberon.com/library/fibonacci)

  第 n 个斐波那契数，其中 F(1) = F(2) = 1。
- [euler_e](https://zh.hilberon.com/library/euler_e)

  第 n 个欧拉数。
- [from_continued_fraction](https://zh.hilberon.com/library/from_continued_fraction)

  连分数所表示的数。
- [divisors](https://zh.hilberon.com/library/divisors)

  一个整数的所有正因数，按从小到大排列。

---
Source: https://zh.hilberon.com/library/extended_gcd
