igcd

Greatest common divisor of integers and complex numbers with integer real and imaginary parts

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

igcd(i1, i2, …)

Description

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.

Examples

Example 1

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)

Example 2

Compute the greatest common divisor of the following complex numbers:

igcd(-10*I, 6), igcd(10 - 5*I, 20 - 10*I, 30 - 15*I)

Example 3

The following example shows some special cases:

igcd(), igcd(0), igcd(1), igcd(-1), igcd(2)

Example 4

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))

Parameters

i1, i2, …

arithmetical expressions representing integers or arithmetical expressions representing complex numbers of the domain DOM_COMPLEX, of which both the real part and the imaginary part are integers.

Return Values

Nonnegative integer, a complex number both the real and imaginary parts of which are integers, or a symbolic igcd call.

See Also

MuPAD Functions

Was this topic helpful?