ComfyUI Node

M Int LCM

The least common multiple node nobody knew they didn't need

By Madlumi·Created 8 months ago·Updated 8 months ago· 0
M Int LCM
    • lcm
    a0
    b0

    The least common multiple is the number-theory cousin of gcd, and it has a genuinely neat ComfyUI use that makes this node more than trivia: it's the smallest number that's divisible by both inputs, which is exactly the question "what's the smallest canvas size that both of my tile grids divide cleanly into?"

    lcm(a, b) returns that value as an INT named lcm. The implementation is the classic formula - a // gcd(a, b) * b - so it inherits correct behavior from the pack's gcd handling. Two details worth knowing: lcm(0, anything) is 0, and the result is always non-negative. Inputs a and b are signed 32-bit INT, defaults 0.

    Where it earns its keep, in the rare workflows that need it:

    • Harmonizing grids. If you have two tiling or batching schemes with different tile sizes, their least common multiple is the smallest dimension where both align - no seams, no partial tiles.
    • Sync points. In multi-pass or interleaved workflows, lcm tells you the frame count where two periodic patterns line up again. That's the "everything is in phase" number.
    • Composing with gcd. GCD finds the common factor, LCM finds the common multiple - together they're the full toolkit for "make these numbers work together."

    It ships in ComfyUiNodes (repo Madlumi/ComfyUiNodes, author "Madanie"), a small personal pack of integer math, string helpers, and workflow-glue nodes. Install via ComfyUI Manager - search "ComfyUiNodes" - or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Madlumi/ComfyUiNodes
    

    Restart ComfyUI after that. No pip requirements or model downloads. It's under Add Node → mnodes → int.

    Real talk: for 99% of users this node will never fire, and that's fine. It exists because the author wanted it. But if you've ever wrestled two tiling schemes into alignment, you know the exact moment you'd reach for it - and now it's one click away.

    Categorymnodes/int

    Inputs (2)

    NameTypeDefaultDescription
    aINT0-2147483648–2147483647
    bINT0-2147483648–2147483647

    Outputs (1)

    NameTypeDescription
    lcmINT