Skip to content

IntGCD

IntGCD

Description

Compute the greatest common divisor of two integers.

Parameters

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

Usage example (from documentation)

  IntGCD(&gcd, &a, &b);

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    void IntGCD(Int *result, Int *a, Int *b) {
        ValidateInt(result);
        ValidateInt(a);
        Int lcm      = IntInit();
    
        IntGCD(&gcd, a, b);
        IntDiv(&quotient, a, &gcd);
        IntMul(&lcm, &quotient, b);
    
    bool test_int_gcd(void) {
        WriteFmt("Testing IntGCD\n");
    
        Int a = IntFrom(48);
        Int result_value = IntInit();
    
        IntGCD(&result_value, &a, &b);
    
        bool result = IntToU64(&result_value) == 6;
Last updated on