FLINT3.7.0-dev

gr_generic_fib2_fmpz, gr_generic_fib_fmpz, gr_generic_fib_ui, gr_generic_fib_vec

Synopsis#include <flint/gr_special.h>
int gr_generic_fib2_fmpz(gr_ptr v, gr_ptr u, const fmpz_t n, gr_ctx_t ctx)source
int gr_generic_fib_fmpz(gr_ptr res, const fmpz_t n, gr_ctx_t ctx)source
int gr_generic_fib_ui(gr_ptr res, ulong n, gr_ctx_t ctx)source
int gr_generic_fib_vec(gr_ptr res, slong len, gr_ctx_t ctx)source

Fibonacci numbers by a table for small n and otherwise the doubling formulas F_{2k-1} = F_k^2 + F_{k-1}^2, F_{2k+1} = 4F_k^2 - F_{k-1}^2 + 2(-1)^k along the binary expansion of n. gr_generic_fib2_fmpz sets v to F_n and u to F_{n-1}. The vec version uses the recurrence.

Cite this page

The FLINT team, “gr_generic_fib2_fmpz, gr_generic_fib_fmpz, gr_generic_fib_ui, gr_generic_fib_vec (gr_special.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/gr_special/gr_generic_fib2_fmpz.html (generated 2026-10-20).