gmp_lib.mpz_fib_ui Method

GMP Native Interface for .NET

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
)
Public Shared Sub mpz_fib_ui ( 
	fn As mpz_t,
	n As UInteger
)
public:
static void mpz_fib_ui(
	mpz_t^ fn, 
	unsigned int n
)
static member mpz_fib_ui : 
        fn : mpz_t * 
        n : uint32 -> unit 

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);
' Create, initialize, and set the value of fn to 0.
Dim fn As New mpz_t()
gmp_lib.mpz_init(fn)

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

' 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)

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