integer-gcd

▸ function gcdInt (a: number, b: number): number

Defined in gcd/double/integer-gcd.ts:9

Computes the greatest common divisor of two integers a and b, using the Euclidean Algorithm.

precondition a, b must be integers

Parameters:

NameType
anumber
bnumber

Returns: number


▸ function gcdInts (vals: number[]): number

Defined in gcd/double/integer-gcd.ts:85

Naively computes and returns the greatest common divisor of 2 or more integers by taking each integer in turn and calculating the GCD of that integer and the previously calculated GCD (where the first GCD is simply taken as the first number).

Parameters:

NameTypeDescription
valsnumber[]the integers for which the GCD is to be calculated

Returns: number