Files
ComfyUI_frontend/src/utils/mathUtil.ts
2025-03-03 15:23:47 -05:00

22 lines
539 B
TypeScript

/**
* 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)
}