FLINT3.7.0-dev

fmpz_mod_rand_not_zero

Synopsis#include <flint/fmpz_mod.h>
void fmpz_mod_rand_not_zero(fmpz_t a, flint_rand_t state, const fmpz_mod_ctx_t ctx)source

Sets a to a random nonzero residue: it draws up to three uniformly random residues and returns the first nonzero one, or 1 if all three are zero. (For n = 1 there is no nonzero residue, and the result is the non-canonical value 1.)

Cite this page

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