Click or drag to resize
gmp_libmpz_lucnum_ui Method
Sets ln to to L[n], the n’th Lucas number.

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_lucnum_ui(
	mpz_t ln,
	uint n
)

Parameters

ln
Type: Math.Gmp.Nativempz_t
The L[n] result.
n
Type: SystemUInt32
The operand integer.
Remarks

The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both mpz_fib2_ui and mpz_lucnum2_ui. The formulas for going from Fibonacci to Lucas can be found in GNU MP - Lucas Numbers Algorithm, the reverse is straightforward too.

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

// Set ln to the 9'th Lucas number.
gmp_lib.mpz_lucnum_ui(ln, 9U);

// Assert that ln is 76.
Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76);

// Release unmanaged memory allocated for ln.
gmp_lib.mpz_clear(ln);
See Also