Function Xgcd - Mathlion - Read The Docs

Mathlion
  • Home
  • Installation
  • Mathematical costants
  • Mathematical operators
  • Units of measurement
  • Mathematical Functions
  • Functions list
    • Abs
    • Acos
    • Acosh
    • Acot
    • Acoth
    • Acsc
    • Acsch
    • Add
    • And
    • Arg
    • Asec
    • Asech
    • Asin
    • Asinh
    • Atan
    • Atan2
    • Atanh
    • bellNumbers
    • Bignumber
    • bitAnd
    • bitNot
    • bitOr
    • bitXor
    • Boolean
    • Catalan
    • Cbrt
    • Ceil
    • Chain
    • Combinations
    • Compare
    • Complex
    • Composition
    • Concat
    • Config
    • Conj
    • Cos
    • Cosh
    • Cot
    • Coth
    • createUnit
    • Cross
    • Csc
    • Csch
    • Cube
    • deepEqual
    • Det
    • Diag
    • Distance
    • Divide
    • Dot
    • dotDivide
    • dotMultiply
    • dotPow
    • Equal
    • Exp
    • Eye
    • Factorial
    • Filter
    • Fix
    • Flatten
    • Floor
    • Fraction
    • Gamma
    • Gcd
    • Hypot
    • Im
    • Intersect
    • Inv
    • isInteger
    • isNaN
    • isNegative
    • isNumeric
    • isPositive
    • isPrime
    • isZero
    • Kldivergence
    • Larger
    • largerEq
    • Lcm
    • leftShift
    • Log
    • Log10
    • Lsolve
    • Lup
    • Lusolve
    • Matrix
    • Max
    • Mean
    • Median
    • Min
    • Mod
    • Mode
    • Multinomial
    • Multiply
    • Norm
    • Not
    • nthRoot
    • Number
    • Ones
    • Or
    • partitionSelect
    • Permutations
    • pickRandom
    • Pow
    • Prod
    • quantileSeq
    • Random
    • randomInt
    • Range
    • Re
    • Resize
    • rightArithShift
    • rightLogShift
    • Round
    • Sec
    • Sech
    • Sign
    • Sin
    • Sinh
    • Size
    • Slu
    • Smaller
    • smallerEq
    • Sort
    • Sparse
    • splitUnit
    • Sqrt
    • Square
    • Squeeze
    • Std
    • stirlingS2
    • String
    • Subset
    • Subtract
    • Sum
    • Tan
    • Tanh
    • To
    • Trace
    • Transpose
    • unaryMinus
    • unaryPlus
    • Unequal
    • Unit
    • Usolve
    • Var
    • Xgcd
      • Function xgcd
        • Syntax
        • Examples
        • See also
    • Xor
    • Zeros
  • Release
Mathlion
  • Docs »
  • Functions list »
  • Xgcd
  • Edit on GitHub
Function xgcd

Calculate the extended greatest common divisor for two values. See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm.

Syntax

xgcd(a, b)

Parameters

Parameter Type Description
a number | BigNumber An integer number
b number | BigNumber An integer number

Returns

Type Description
Array Returns an array containing 3 integers [div, m, n] where div = gcd(a, b) and a*m + b*n = div

Examples

xgcd(8, 12); // returns [4, -1, 1] gcd(8, 12); // returns 4 xgcd(36163, 21199); // returns [1247, -7, 12]

See also

gcd, lcm

Từ khóa » Xgcd