Here's a TypeScript function that uses the Euclidean algorithm to find the greatest common divisor of an array of numbers:
index.ts312 chars15 linesThe gcd function takes an array of numbers and iteratively calls gcdTwoNumbers to find the greatest common divisor of all the numbers in the array. The gcdTwoNumbers function uses the Euclidean algorithm to find the greatest common divisor of two numbers.
gistlibby LogSnag