Click or drag to resize
gmp_libmpz_legendre Method
Calculate the Legendre symbol (a/p).

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_legendre(
	mpz_t a,
	mpz_t p
)

Parameters

a
Type: Math.Gmp.Nativempz_t
The first operand integer.
p
Type: Math.Gmp.Nativempz_t
The second operand integer.

Return Value

Type: Int32
The Legendre symbol (a/p).
Remarks

This is defined only for p an odd positive prime, and for such p it’s identical to the Jacobi symbol.

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

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

// Assert that the Legendre symbol of (a/p) is 1.
Assert.IsTrue(gmp_lib.mpz_legendre(a, p) == 1);

// Release unmanaged memory allocated for a and p.
gmp_lib.mpz_clears(a, p, null);
See Also