gmp_lib.mpz_gcd Method

GMP Native Interface for .NET

gmp_libmpz_gcd Method
Set rop to the greatest common divisor of op1 and op2.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static void mpz_gcd(
	mpz_t rop,
	mpz_t op1,
	mpz_t op2
)
Public Shared Sub mpz_gcd ( 
	rop As mpz_t,
	op1 As mpz_t,
	op2 As mpz_t
)
public:
static void mpz_gcd(
	mpz_t^ rop, 
	mpz_t^ op1, 
	mpz_t^ op2
)
static member mpz_gcd : 
        rop : mpz_t * 
        op1 : mpz_t * 
        op2 : mpz_t -> unit 

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result operand integer.
op1
Type: Math.Gmp.Nativempz_t
The first operand integer.
op2
Type: Math.Gmp.Nativempz_t
The second operand integer.
Remarks

The result is always positive even if one or both input operands are negative. Except if both inputs are zero; then this function defines gcd(0,0) = 0.

Examples
// Create, initialize, and set the value of op1 to 63.
mpz_t op1 = new mpz_t();
gmp_lib.mpz_init_set_ui(op1, 63U);

// Create, initialize, and set the value of op2 to 70.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init_set_ui(op2, 70U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the greatest common divisor of op1 and op2.
gmp_lib.mpz_gcd(rop, op1, op2);

// Assert that rop is 7.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 7);

// Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, null);
' Create, initialize, and set the value of op1 to 63.
Dim op1 As New mpz_t()
gmp_lib.mpz_init_set_ui(op1, 63UI)

' Create, initialize, and set the value of op2 to 70.
Dim op2 As New mpz_t()
gmp_lib.mpz_init_set_ui(op2, 70UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the greatest common divisor of op1 and op2.
gmp_lib.mpz_gcd(rop, op1, op2)

' Assert that rop is 7.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 7)

' Release unmanaged memory allocated for rop, op1, and op2.
gmp_lib.mpz_clears(rop, op1, op2, Nothing)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also