FUNCTION REFERENCE

gcd

Greatest common divisor.

Greatest common divisor.

Syntax

g = gcd(a, b)

Syntax

[g, c, d] = gcd(a, b)

Elementwise on integer-valued a and b (one may be a scalar); g is never

negative.

With three outputs, g = a.*c + b.*d.

Example

gcd(12, 18)   % 6

Differences from MATLAB: Real double and logical input only; both inputs must

have equal size or one must be a scalar; no integer classes.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.