# Extended Euclidean algorithm (extended_gcd)

Greatest common divisor of two whole numbers with the multipliers that give it.

## How to write it

### extended_gcd(a, b)

**a**

A whole number. Takes a whole number.

**b**

A whole number. Takes a whole number.

## Examples

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

  `extended_gcd(12, 18)`

  In the solver, `extended_gcd(12, 18)` gives `[6, [-1, 1]]`.

  [Open in the solver](https://hilberon.com/?q=extended_gcd%2812%2C%2018%29)

## Related functions

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

  Prime factorization of a whole number, as a list of prime and exponent pairs.
- [euler_phi](https://hilberon.com/library/euler_phi)

  Euler's totient: how many whole numbers up to n are coprime to n.
- [fibonacci](https://hilberon.com/library/fibonacci)

  The n-th Fibonacci number, with F(1) = F(2) = 1.
- [euler_e](https://hilberon.com/library/euler_e)

  The n-th Euler number.
- [from_continued_fraction](https://hilberon.com/library/from_continued_fraction)

  The number a continued fraction stands for.
- [divisors](https://hilberon.com/library/divisors)

  The positive divisors of a whole number, in increasing order.

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