> 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/g/greatest_common_divisor.md).

# Greatest common divisor

### Built-in

```ruby
var arr = [100, 1_000, 10_000, 20]
say Math.gcd(arr...)
```

### Recursive Euclid algorithm

```ruby
func gcd(a, b) {
    b==0 ? a.abs : gcd(b, a % b)
}
```
