gmp_lib.mpz_congruent_p Method

GMP Native Interface for .NET

gmp_libmpz_congruent_p Method
Return non-zero if n is congruent to c modulo d.

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 int mpz_congruent_p(
	mpz_t n,
	mpz_t c,
	mpz_t d
)
Public Shared Function mpz_congruent_p ( 
	n As mpz_t,
	c As mpz_t,
	d As mpz_t
) As Integer
public:
static int mpz_congruent_p(
	mpz_t^ n, 
	mpz_t^ c, 
	mpz_t^ d
)
static member mpz_congruent_p : 
        n : mpz_t * 
        c : mpz_t * 
        d : mpz_t -> int 

Parameters

n
Type: Math.Gmp.Nativempz_t
An operand integer.
c
Type: Math.Gmp.Nativempz_t
The remainder of the division by d.
d
Type: Math.Gmp.Nativempz_t
The divisor operand integer.

Return Value

Type: Int32
Non-zero if n is congruent to c modulo d.
Remarks

n is congruent to c mod d if there exists an integer q satisfying n = c + q * d. Unlike the other division functions, d = 0 is accepted and following the rule it can be seen that n and c are considered congruent mod 0 only when exactly equal.

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

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

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

// Assert that n is congruent to c mod d.
Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0);

// Release unmanaged memory allocated for n, d, and c.
gmp_lib.mpz_clears(n, d, c, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_ui(n, 10000UI)

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

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

' Assert that n is congruent to c mod d.
Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0)

' Release unmanaged memory allocated for n, d, and c.
gmp_lib.mpz_clears(n, d, c, 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