Click or drag to resize
gmp_libmpz_bin_ui Method
Compute the binomial coefficient n over k and store the result in rop.

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_bin_ui(
	mpz_t rop,
	mpz_t n,
	uint k
)

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: Math.Gmp.Nativempz_t
The first operand integer.
k
Type: SystemUInt32
The second operand integer.
Remarks

Negative values of n are supported by mpz_bin_ui, using the identity bin(-n, k) = (-1)^k * bin(n + k - 1, k), see Knuth volume 1 section 1.2.6 part G.

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

// 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 binomial coefficient (n:2).
gmp_lib.mpz_bin_ui(rop, n, 2U);

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

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