igcd
Greatest common divisor of integers and complex numbers with integer real and imaginary parts
MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
igcd(i1
, i2, …
)
igcd(i1, i2, ...)
computes the greatest common
divisor of the integers i1, i2,
…
igcd
computes the greatest common nonnegative
divisor of a sequence of integers.
If an argument of igcd
is a single integer number,
the function returns the absolute value of that argument.
igcd
also computes the greatest common divisor
of a sequence of complex numbers of the domain DOM_COMPLEX
. Both the
real and the imaginary parts of all complex numbers in a sequence
must be integers. The greatest common
divisor is a complex number with a positive real part and a nonnegative
imaginary part.
If all arguments are 0
, igcd
returns 0
.
If there are no arguments, igcd
also returns 0
.
If one argument is a number, but is neither an integer nor
a complex number with integer real and imaginary parts, then igcd
returns
an error message.
If at least one of the arguments is 1
or -1
, igcd
returns 1
.
Otherwise, if one argument is not a number, the igcd
function
returns a symbolic igcd
call.
Compute the greatest common divisor of the following integers:
igcd(-10, 6), igcd(6, 10, 15)
a := 4420, 128, 8984, 488: igcd(a), igcd(a, 64)
Compute the greatest common divisor of the following complex numbers:
igcd(-10*I, 6), igcd(10 - 5*I, 20 - 10*I, 30 - 15*I)
The following example shows some special cases:
igcd(), igcd(0), igcd(1), igcd(-1), igcd(2)
If one argument is not a number, then the result is a symbolic igcd
call.
However, if at least one of the arguments is 1
or -1
,
the greatest common divisor is always 1
:
delete x: igcd(a, x), igcd(1, x), igcd(-1, x)
type(igcd(a, x))
|
arithmetical
expressions representing integers or arithmetical expressions representing
complex numbers of the domain |
Nonnegative integer, a complex
number both the real and imaginary parts of which are integers, or
a symbolic igcd
call.