Click or drag to resize
gmp_libmpz_fib_ui Method
Sets fn to to F[n], the n’th Fibonacci 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_fib_ui(
	mpz_t fn,
	uint n
)

Parameters

fn
Type: Math.Gmp.Nativempz_t
The F[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 fn to 0.
mpz_t fn = new mpz_t();
gmp_lib.mpz_init(fn);

// Set fn to the n'th Fibonacci number.
gmp_lib.mpz_fib_ui(fn, 20U);

// Assert that fn is 6765.
Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765);

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