FLINT3.7.0-dev

_arith_bernoulli_number_vec_recursive

Synopsis#include <flint/arith.h>
void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, slong n)source

Sets the numerators and denominators of B_0, \ldots, B_{n-1} using Ramanujan's recurrence, which expresses B_m in terms of the B_k with k \equiv m \pmod 6. Intended for n up to a few thousand.

The first values are taken from a table. The recurrence is then run with all numerators over the common denominator (n+1)\# (the primorial), so that only integer additions and multiplications by binomial coefficients are needed; the binomial coefficients are updated with products of up to six small factors per word. The cost is O(n^2) operations on numbers of O(n \log n) bits. The function throws for n beyond about 3 \cdot 10^9 (64-bit), where the word-size products would overflow.

Cite this page

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