Least common multiple of integers

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.


ilcm(i1, i2, …)


ilcm(i1, i2, ...) computes the least common multiple of the integers i1, i2, …

ilcm computes the least common nonnegative multiple of a sequence of integers. ilcm with a single numeric argument returns its absolute value. ilcm returns 1 when all arguments are 1 or -1 or no argument is given.

ilcm returns an error message when one of the arguments is a number but not an integer. If at least one of the arguments is 0, then ilcm returns 0. Otherwise, if one argument is not a number, then a symbolic ilcm call is returned.


Example 1

We compute the least common multiple of some integers:

ilcm(-10, 6), ilcm(6, 10, 15)

a := 4420, 128, 8984, 488:
ilcm(a), ilcm(a, 64)

The next example shows some special cases:

ilcm(), ilcm(0), ilcm(1), ilcm(-1), ilcm(2)

If one argument is not a number, then the result is a symbolic ilcm call, except in some special cases:

delete x:
ilcm(a, x), ilcm(0, x)

type(ilcm(a, x))


i1i2, …

arithmetical expressions representing integers

Return Values

Nonnegative integer, or a symbolic ilcm call.

See Also

MuPAD Functions