n_is_perfect_power235, n_factor_power235
Synopsis
#include <flint/ulong_extras.h>n_is_perfect_power235 returns whether n is a square, cube or fifth power. n_factor_power235 returns the root r and sets *exp to k \in \{2, 3, 5\} if n = r^k, and otherwise returns 0.
Both functions first apply a sequence of modular tests, which rejects most inputs: each test looks up a 3-bit mask saying whether n can be a square, cube or fifth power modulo some small modulus, and the masks are combined with bitwise AND. For any bit that survives, the corresponding root is computed and checked exactly.
Cite this page
The FLINT team, “n_is_perfect_power235, n_factor_power235 (ulong_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ulong_extras/n_is_perfect_power235.html (generated 2026-10-20).
@misc{flint-doc-ulong-extras-n-is-perfect-power235,
author = {{The FLINT team}},
title = {{n\_is\_perfect\_power235, n\_factor\_power235 (ulong\_extras.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/ulong_extras/n_is_perfect_power235.html},
note = {Generated 2026-10-20}
}