---
title: "gcd function in Strata | Oplema"
description: "Calculate the greatest common divisor of two integers, the largest number that divides both. For example, gcd(42, 57) returns 3."
url: "https://oplema.com/docs/strata/functions/gcd"
updated: "2026-11-04"
---

# gcd

Find the largest whole number that divides two numbers exactly.

Also available as greatest\_common\_divisor.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **BIGINT**.

### Expression

```
gcd(42, 57)
```

### Result

```
3
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | 3 |

## Arguments and types

```
gcd(x, y)
```

**x**

Number

**y**

Number

Supported signatures (2)

```
gcd(x: BIGINT, y: BIGINT) → BIGINT
gcd(x: HUGEINT, y: HUGEINT) → HUGEINT
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[greatest\_common\_divisor

Find the largest whole number that divides two numbers exactly.

](https://oplema.com/docs/strata/functions/greatest-common-divisor)[lcm

Find the smallest whole number that two numbers both divide into exactly.

](https://oplema.com/docs/strata/functions/lcm)[least\_common\_multiple

Find the smallest whole number that two numbers both divide into exactly.

](https://oplema.com/docs/strata/functions/least-common-multiple)[acos

Computes the arccosine of x.

](https://oplema.com/docs/strata/functions/acos)

[Browse numbers](https://oplema.com/docs/strata/functions#numbers) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/numeric.html#gcdx-y)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
