Functional Weave
Code in TypeScript

math.gcd-lcm@2.0.0

impl/python/gcd_lcm.py

417 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from .math_gcd_lcm_gcd import gcd  ← gcd, another function of this group · built into the same file, even by a slim install
from .math_gcd_lcm_lcm import lcm  ← lcm, another function of this group · built into the same file, even by a slim install
from .math_gcd_lcm_types import GcdLcm


def gcd_lcm(a: int, b: int) -> GcdLcm:
    """Greatest common divisor and least common multiple of two integers.

    Both are returned together because a caller needing one nearly always
    needs the other (common denominators, repeating schedules).
    """
    return GcdLcm(gcd=gcd(a, b), lcm=lcm(a, b))