FLINT3.7.0-dev

mpn_mod_pow_ui, mpn_mod_pow_fmpz

Synopsis#include <flint/mpn_mod.h>
int mpn_mod_pow_ui(nn_ptr res, nn_srcptr x, ulong e, gr_ctx_t ctx)source
int mpn_mod_pow_fmpz(nn_ptr res, nn_srcptr x, const fmpz_t e, gr_ctx_t ctx)source

Set res to x^e \bmod n, with 0^0 = 1. A negative exponent requires x to be invertible and otherwise gives the status of mpn_mod_inv.

Exponents e \le 64 (pow_ui) or of at most 6 bits (pow_fmpz) use binary exponentiation with mpn_mod_mul (gr_generic_pow_ui, gr_generic_pow_fmpz); larger exponents call GMP's mpz_powm. Negative exponents go through the generic code.

Cite this page

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