Skip to content

IntLCM

Description

Compute the least common multiple of two integers.

Parameters

Name Direction Description
result out Destination for the LCM
a in First operand
b in Second operand

Usage example (from documentation)

  IntLCM(&lcm, &a, &b);

Success

Returns true. *result holds lcm(a, b).

Failure

Returns false on allocator OOM while growing result. *result is left untouched.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool IntLCM(Int *result, const Int *a, const Int *b) {
        ValidateInt(result);
        ValidateInt(a);
    
    bool test_int_lcm(void) {
        WriteFmt("Testing IntLCM\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int result_value = IntInit(&alloc.base);
    
        IntLCM(&result_value, &a, &b);
    
        bool result = IntToU64(&result_value) == 42;
Last updated on