[Refactor] Add util to merge input spec (#2834)

This commit is contained in:
Chenlei Hu
2025-03-03 15:23:47 -05:00
committed by GitHub
parent f76995a3b9
commit 603825b2a0
6 changed files with 407 additions and 109 deletions

21
src/utils/mathUtil.ts Normal file
View File

@@ -0,0 +1,21 @@
/**
* Finds the greatest common divisor (GCD) for two numbers.
*
* @param a - The first number.
* @param b - The second number.
* @returns The GCD of the two numbers.
*/
export const gcd = (a: number, b: number): number => {
return b === 0 ? a : gcd(b, a % b)
}
/**
* Finds the least common multiple (LCM) for two numbers.
*
* @param a - The first number.
* @param b - The second number.
* @returns The LCM of the two numbers.
*/
export const lcm = (a: number, b: number): number => {
return Math.abs(a * b) / gcd(a, b)
}