TS-Scribe - v0.6.2
    Preparing search index...

    Function greatestCommonDivisor

    • Calculates the greatest common divisor (GCD) of multiple numbers. The function uses the Euclidean algorithm to calculate the GCD of the given set of values. It iteratively reduces the set of values to find the greatest common divisor.

      Parameters

      • ...values: number[]

        A list of numbers to find the GCD of.

      Returns number

      The greatest common divisor of the provided numbers.

      greatestCommonDivisor(12, 15, 21);     // Returns 3
      greatestCommonDivisor(50, 75, 100); // Returns 25
      greatestCommonDivisor(9, 12, 15, 18); // Returns 3