ComfyUI Node

Is Prime?

The node this entire pack started as a joke about

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Is Prime?
    • BOOLEAN
    value1
    threshold10000000
    miller_rabin_rounds5

    This is the origin story of the whole pack, more or less. LogicUtils' README opens with a crossed-out line - "prime list calculation in comfyui" - as the joke premise that supposedly kicked the repo off, before it ballooned into dozens of unrelated tagger, image, and data nodes. This node is the part of that joke that's actually real: feed it an integer, it tells you whether it's prime.

    It's not a toy implementation either. Under a configurable threshold, it checks primality by exact deterministic testing - fast and always correct for numbers that size. Above the threshold, brute-force division gets too slow, so it switches to the Miller-Rabin primality test, a probabilistic algorithm that trades a tiny, tunable chance of a wrong answer for the ability to test genuinely huge numbers quickly. miller_rabin_rounds controls that trade-off: more rounds, lower odds of a false positive. Five rounds (the default) already pushes the worst-case error rate down around one in a thousand, and in practice - for numbers that aren't adversarially constructed to fool it - it's far more reliable than that. This is standard textbook number theory, the same test cryptographic libraries lean on, just wired into a node graph for reasons that remain delightfully unclear.

    Inputs and outputs

    • value - the integer to test, anywhere from about -10 billion to +10 billion.
    • threshold (default 10,000,000) - below this, exact trial division; above it, Miller-Rabin kicks in.
    • miller_rabin_rounds (default 5, max 50) - more rounds if you want extra confidence on huge numbers; the default is already solid for everyday use.

    Output is a single BOOLEAN. Feed it 0, 1, or a negative number and you'll just get false back - none of those are prime by any definition, the wide input range just means the widget won't stop you from trying.

    Installing ComfyUI-LogicUtils

    ComfyUI Manager: Install Custom Nodes → search "ComfyUI-LogicUtils" → install → restart. Manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aria1th/ComfyUI-LogicUtils
    

    Restart ComfyUI. Pure Python, no models, no extra dependencies - the whole node is arithmetic.

    Worth knowing

    This is aria1th's (AngelBottomless, of Illustrious XL fame - a separate, much bigger project from this one) side pack of utility nodes, and it's genuinely a grab-bag: math nodes like this one sit next to Danbooru taggers and JSON dumpers with no unifying theme beyond "things I wanted while building ComfyUI workflows." The repo picked up a real community shout-out on r/StableDiffusion in January 2026 as the lightweight, no-dependency option when you need one small utility node and don't want to drag in a heavier pack for it - and that thread landed the same month public pushes to LogicUtils stopped. So don't expect updates, but also don't expect much to go wrong: a primality checker has had the same job since long before ComfyUI existed, and it isn't going to regress.

    CategoryMath

    Inputs (3)

    NameTypeDefaultDescription
    valueINT1-9999999999–9999999999
    thresholdoptINT100000001–9999999999
    miller_rabin_roundsoptINT51–50

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN