extgcd

1.0.0 • Public • Published

extgcd

Compute the gcd and solve Bezout's identity using the extended Euclidean algorithm.

usage

var extgcd = require('extgcd');
console.log(extgcd(56, 15));
 
/**
 * Will output gcd, x and y such that 56x + 15y = gcd.
 * {
 *     gcd: 1,
 *     x: -4,
 *     y: 15
 * }
 */

methods

extgcd(a, b)

Returns an object containing the gcd, and the solution (x, y) to Bezout's identity.

{
    gcd: gcd,
    x: x,
    y: y
}

Package Sidebar

Install

npm i extgcd

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

3.94 kB

Total Files

5

Last publish

Collaborators

  • mpeinhopf