gmp_libmpz_fib_ui Method |
Namespace: Math.Gmp.Native
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
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.
// 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.