mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 05:19:53 +00:00
22 lines
539 B
TypeScript
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)
|
|
}
|