Loading [Contrib]/a11y/accessibility-menu.js

gcd

Returns the greatest common deviser of the set x.

Syntax

g = gcd(x1,x2,...)

[g,v1,...] = gcd(x1,x2,...)

Inputs

x1,x2,...
The elements to find the greatest common divisor of.
Type: double | integer
Dimension: scalar | vector

Outputs

g
The greatest common divisor of the set.
Resulting scalar | vector
v1,...
Vectors containing integers that, when multiplied by the corresponding x elements and summed up, are equal to the greatest common divisor g.
Resulting scalar | vector

Example

Simple gcd example:

gcd([20 44], [8 11])
ans = [Matrix] 1 x 2
4  11

Simple gcd example:

[g,v1]=gcd([20 44], [8 11])
g = [Matrix] 1 x 2
4  11
v1 = [Matrix] 1 x 2
1  0