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 aa modulo the prime pp that lies in [0,p/2][0, p/2], or 0 if aa is not a square. Requires a<pa < p.

If pp is not prime, the result is either 0 or a genuine square root of aa modulo pp. This is a wrapper of nmod_sqrt, which should be called directly when an nmod_t for pp 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-11-02).