> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/l/least_common_multiple.md).

# Least common multiple

Built-in:

```ruby
say Math.lcm(1001, 221)
```

Using GCD:

```ruby
func gcd(a, b) {
    while (a) { (a, b) = (b % a, a) }
    return b
}
 
func lcm(a, b) {
    (a && b) ? (a / gcd(a, b) * b) : 0
}
 
say lcm(1001, 221)
```

#### Output:

```
17017
```
