Least common multiple

### 6.1.3 Least common multiple

The lcm command finds the least common multiple (LCM) of a set of integers or polynomials. (See also Section 10.3.7 for polynomials.)

- lcm can take seq, a sequence or list of integers or polynomials, as its only argument.
- lcm(seq) returns the LCM of the elements of s.
- Alternatively, lcm can take s and t, two lists of the same length containing integers or polynomials (alternatively, a matrix m with two rows whose elements are integers or polynomials).
- lcm(s,t) (or lcm(m)) returns the list whose kth element is the LCM of the kth elements of s and t (or the kth column of m).

#### Examples

lcm(18,15)

90 |  |  |  |  |  |  |  |  |  |

lcm(-5-12*i,11-10*i)

−53+8 i |  |  |  |  |  |  |  |  |  |

lcm(18,15,21,36)

1260 |  |  |  |  |  |  |  |  |  |

lcm([18,15,21,36])

1260 |  |  |  |  |  |  |  |  |  |

lcm([6,10,12],[21,5,8])

or:

lcm([[6,10,12],[21,5,8]])

| ⎡ ⎣ | 42,10,24 | ⎤ ⎦