Documentation

    greatest_common_divisor

    Find the largest whole number that divides two numbers exactly.

    Also available as gcd.

    Try an expression

    In Formula, enter the expression and set Output type to BIGINT.

    Expression

    greatest_common_divisor(42, 57)

    Result

    3

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

    Arguments and types

    greatest_common_divisor(x, y)
    x
    Number
    y
    Number
    Supported signatures (2)
    greatest_common_divisor(x: BIGINT, y: BIGINT) → BIGINT
    greatest_common_divisor(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.

    Browse numbersDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.