diff --git a/prometheus/utils.py b/prometheus/utils.py new file mode 100644 index 0000000000..9feae6067c --- /dev/null +++ b/prometheus/utils.py @@ -0,0 +1,22 @@ + def gcd(a: int, b: int) -> int: + """ + Euclidean algorithm to find the greatest common divisor of two numbers. + + :param a: The first integer. + :param b: The second integer. + :return: The greatest common divisor of a and b. + """ + while b: + a, b = b, a % b + return abs(a) + + +def lcm(a: int, b: int) -> int: + """ + Calculate the least common multiple of two numbers using the formula: lcm(a, b) = |a*b| / gcd(a, b). + + :param a: The first integer. + :param b: The second integer. + :return: The least common multiple of a and b. + """ + return abs(a * b) // gcd(a, b) \ No newline at end of file