Function gcd

  • Greatest common divisor of two integers.

    Zero is treated as the identity element: gcd(0, x) = gcd(x, 0) = x

    The sign of the result is essentially random for negative inputs.

    Parameters

    • a: number

      The first integer.

    • b: number

      The second integer.

    Returns number

    The largest integer that divides a and b.

  • Parameters

    • a: bigint
    • b: bigint

    Returns bigint