FLINT3.7.0-dev

flint_mpn_divisible

Synopsis#include <flint/mpn_extras.h>
int flint_mpn_divisible(mp_srcptr a, mp_size_t an, mp_srcptr b, mp_size_t bn)source

Returns 1 if bb divides aa and 0 otherwise. Requires bn≥1\mathit{bn} \ge 1 and bbn−1≠0b_{bn-1} \ne 0; aa may have zero top limbs and an\mathit{an} may be zero or less than bn\mathit{bn}. Used by fmpz_divisible.

After the trivial cases and the 2-adic part (b=2vBkb′b = 2^v B^k b' with b′b' odd), one-limb b′b' use the Hensel remainder mpn_modexact_1_odd. When both the divisor and the quotient have at least 16 limbs, the operands are first screened modulo 248−12^{48} - 1 (which has nine small prime factors; flint_mpn_mod_2exp48m1): a prime dividing bb but not aa is revealed for about 60% of random pairs. Then, with m=an−bn+1m = \mathit{an} - \mathit{bn} + 1: b′b' of at most FLINT_MPN_DIVEXACT_SMALL_BN limbs use _flint_mpn_divisible_small; huge operands (min⁡(m,bn)≥\min(m, \mathit{bn}) \ge FLINT_MPN_DIVEXACT_NEWTON_CUTOFF, or bn≥\mathit{bn} \ge FLINT_MPN_DIVEXACT_UNBALANCED_CUTOFF and m≥8bnm \ge 8 \mathit{bn}) take the candidate quotient from the Newton Hensel division and form only the high part of its product with bb (_flint_mpn_mulhigh_known_low), the low part being known; otherwise, as in GMP's mpn_divisible_p, a Hensel division with remainder (ports of mpn_sbpi1_bdiv_qr and mpn_dcpi1_bdiv_qr, the latter from FLINT_MPN_DC_BDIV_QR_CUTOFF limbs) is done after padding aa so that its top limb is below that of b′b', and b′b' divides aa if and only if the remainder equals b′b'.

Cite this page

The FLINT team, “flint_mpn_divisible (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_divisible.html (generated 2026-11-02).