FLINT3.7.0-dev

n_sqrtmod

Synopsis#include <flint/ulong_extras.h>
ulong n_sqrtmod(ulong a, ulong p)source

Returns the square root of a modulo the prime p that lies in [0, p/2], or 0 if a is not a square. Requires a < p.

If p is not prime, the result is either 0 or a genuine square root of a modulo p. This is a wrapper of nmod_sqrt, which should be called directly when an nmod_t for p is available.

Cite this page

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