nmod_pow_ui, nmod_pow_fmpz
Synopsis
#include <flint/nmod.h>Return a^{\mathit{exp}} \bmod n for reduced a, with a^0 = 1 (which is 0 when n = 1). For a negative exponent, nmod_pow_fmpz returns (a^{-1})^{-\mathit{exp}} and throws FLINT_IMPINV if a is not invertible modulo n.
nmod_pow_ui uses binary exponentiation with n_mulmod_preinv on the normalised modulus. For odd n and \mathit{exp} \ge 2^{11} it uses Montgomery multiplication instead. nmod_pow_fmpz calls n_powmod2_fmpz_preinv, after inverting a with n_gcdinv if the exponent is negative, as n_powmod2_preinv does.
Guides#
Cite this page
The FLINT team, “nmod_pow_ui, nmod_pow_fmpz (nmod.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nmod/nmod_pow_ui.html (generated 2026-10-20).
@misc{flint-doc-nmod-nmod-pow-ui,
author = {{The FLINT team}},
title = {{nmod\_pow\_ui, nmod\_pow\_fmpz (nmod.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/nmod/nmod_pow_ui.html},
note = {Generated 2026-10-20}
}