FLINT3.7.0-dev

n_sqrtmod_2pow, n_sqrtmod_primepow, n_sqrtmodn

Synopsis#include <flint/ulong_extras.h>
slong n_sqrtmod_2pow(ulong ** sqrt, ulong a, slong exp)source
slong n_sqrtmod_primepow(ulong ** sqrt, ulong a, ulong p, slong exp)source
slong n_sqrtmodn(ulong ** sqrt, ulong a, n_factor_t * fac)source

Compute all square roots of a modulo 2^{\mathit{exp}}, modulo p^{\mathit{exp}}, or modulo an integer m given by its factorisation, and return their number. The roots are written to a newly allocated array stored in *sqrt, which the caller frees with flint_free. If a is not a square, 0 is returned and *sqrt is set to NULL.

Cite this page

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