/**
* Calculate the greatest common divisor of two numbers.
* @param {number} a
* @param {number} b
* @returns {number|*} The greatest common divisor of {a} and {b}.
* @throws {TypeError} If either {a} or {b} is not finite.
*/exportfunctiongcd(a,b){a=+a;b=+b;if(!Number.isFinite(a)||!Number.isFinite(b)){thrownewTypeError("Invalid input");}// Euclidean algorithm
functioninner_gcd(a,b){while(b!==0){lett=b;b=a%b;a=t;}returna;}returninner_gcd(a, b);}